This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ spec spec/ | |
Prawn specs: Running on Ruby Version: 1.9.0 | |
.......................F.F.................................................................................................F....................... | |
1) | |
Spec::Mocks::MockExpectationError in 'When ending each page should execute the lambda specified by on_page_end' | |
Mock 'page_end_proc' expected :[] with (any args) 3 times, but received it 0 times | |
/Users/sandal/devel/prawn/spec/document_spec.rb:68:in `block (2 levels) in <top (required)>' | |
2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
04:27 < mindaugas> Hello, i've got problem with prawnto rails plugin, I followed carefully all the steps as described in http://cracklabs.com/prawnto/use but my controller actions still looking for erb templates... and all i get is "template is missing" error. I wonder, what i'm missing ? | |
04:33 < mindaugas> I'm on windows xp with rails 2.1 | |
04:39 < yob> are you calling http://host/controller/action/id.pdf ? | |
04:49 < mindaugas> Thanks yob, your question just put me in the right direction, it works now, i'm still newb :) | |
04:51 < yob> no probs | |
04:51 < yob> the format stuff is black magic if you haven't used it before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "thought" | |
class Thought | |
class SafetyFirst | |
def analyze(map, rover) | |
return unless map.threat.nonzero? | |
if 2 * rover.speed > rover.max_sensor or | |
(rover.rotation_speed and rover.speed > rover.rotation_speed) | |
Vote.new("b*", 99) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pdf = Prawn::Document.new(:page_size => "LEGAL") do | |
text "Blahdiblah" | |
image "my_sexy_pic.png" | |
end | |
pdf.render |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prawn::Document.generate("family_style.pdf") do | |
["Courier","Helvetica","Times-Roman"].each do |f| | |
[:bold,:bold_italic,:italic,:normal].each do |s| | |
font f, :style => s | |
text "I'm writing in #{f} (#{s})" | |
end | |
end | |
font "Helvetica" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = "lazy_bounding_boxes.pdf" | |
Prawn::Document.generate(file, :skip_page_creation => true) do | |
point = [bounds.right-50, bounds.bottom + 25] | |
page_counter = lazy_bounding_box(point, :width => 50) do | |
text "Page: #{page_count}" | |
end | |
10.times do | |
start_new_page | |
text "Some text" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "open-uri" | |
loop do | |
puts( open("http://finance.google.com/finance?cid=983582").read. | |
match(/<span class="chr" id="ref_983582_c">(-?\d+\.\d+)/m)[1] ) | |
sleep(10) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "enumerator" | |
# tree is represented as: [[a,b,c,d],[e,f,g],[h,i],[j]] | |
# (bottom up) | |
# | |
def max(tree) | |
bottom = tree.shift | |
pairs = bottom.enum_for(:each_cons, 2).to_a | |
update = pairs.enum_for(:each_with_index).map do |pair,i| | |
tree.first[i] + pair.max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prawn::Document.generate("span.pdf") do | |
# Spans will typically be used outside of bounding boxes as a way to build | |
# single columns of flowing text that span across pages. | |
# | |
span(350, :position => :center) do | |
text "Here's some centered text in a 350 point column. " * 100 | |
end | |
# Spans are not really compatible with bounding boxes because they break |