Class: Tidewave::ToolbarBody
- Inherits:
-
Object
- Object
- Tidewave::ToolbarBody
- Defined in:
- lib/tidewave.rb
Instance Method Summary collapse
- #close ⇒ Object
- #each {|pending| ... } ⇒ Object
-
#initialize(body, toolbar) ⇒ ToolbarBody
constructor
A new instance of ToolbarBody.
Constructor Details
#initialize(body, toolbar) ⇒ ToolbarBody
Returns a new instance of ToolbarBody.
33 34 35 36 37 |
# File 'lib/tidewave.rb', line 33 def initialize(body, ) @body = body @toolbar = @closed = false end |
Instance Method Details
#close ⇒ Object
64 65 66 67 68 69 |
# File 'lib/tidewave.rb', line 64 def close return if @closed @closed = true @body.close if @body.respond_to?(:close) end |
#each {|pending| ... } ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tidewave.rb', line 39 def each return enum_for(:each) unless block_given? pending = +"" injected = false @body.each do |part| if injected yield part else pending << part if closing_head = pending.downcase.index("</head>") = @toolbar.dup.force_encoding(pending.encoding) output = pending.insert(closing_head, ) pending = nil injected = true yield output end end end yield pending unless injected || pending.empty? end |