Class: Helpers::ContentList
- Inherits:
-
Array
- Object
- Array
- Helpers::ContentList
- Defined in:
- lib/helpers.rb
Instance Attribute Summary collapse
-
#indentation ⇒ Object
Returns the value of attribute indentation.
Instance Method Summary collapse
- #find_tag(&block) ⇒ Object
-
#initialize(items, indentation) ⇒ ContentList
constructor
A new instance of ContentList.
- #inspect ⇒ Object
- #select_tags(&block) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(items, indentation) ⇒ ContentList
Returns a new instance of ContentList.
84 85 86 87 |
# File 'lib/helpers.rb', line 84 def initialize(items, indentation) self.indentation = indentation self.push(*items) end |
Instance Attribute Details
#indentation ⇒ Object
Returns the value of attribute indentation.
83 84 85 |
# File 'lib/helpers.rb', line 83 def indentation @indentation end |
Instance Method Details
#find_tag(&block) ⇒ Object
100 101 102 103 104 |
# File 'lib/helpers.rb', line 100 def find_tag(&block) self.find do |item| block.call(item) if item.respond_to?(:name) end end |
#inspect ⇒ Object
112 113 114 |
# File 'lib/helpers.rb', line 112 def inspect self.to_s end |
#select_tags(&block) ⇒ Object
106 107 108 109 110 |
# File 'lib/helpers.rb', line 106 def (&block) self.select do |item| block.call(item) if item.respond_to?(:name) end end |
#to_s ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/helpers.rb', line 89 def to_s self.map do |item| if item.respond_to?(:indentation) item.indentation = self.indentation item else "#{" " * self.indentation}#{item}" end end.join("\n") end |