Class: Autoini::Section
- Includes:
- InlineComment
- Defined in:
- lib/autoini/section.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes included from InlineComment
Class Method Summary collapse
Instance Method Summary collapse
- #<<(contents) ⇒ Object
- #==(e) ⇒ Object
-
#initialize(title, *contents) ⇒ Section
constructor
A new instance of Section.
- #to_s ⇒ Object
Methods included from InlineComment
Constructor Details
#initialize(title, *contents) ⇒ Section
Returns a new instance of Section.
8 9 10 11 12 |
# File 'lib/autoini/section.rb', line 8 def initialize(title, *contents) @title = title @lines = [] self << contents end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
6 7 8 |
# File 'lib/autoini/section.rb', line 6 def lines @lines end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/autoini/section.rb', line 5 def title @title end |
Class Method Details
Instance Method Details
#<<(contents) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/autoini/section.rb', line 14 def <<(contents) Autoini.wrap(contents).each do |c| unless c.is_a?(AbstractLine) raise ArgumentError, "#{c.class.name} must extend Autoini::AbstractLine" end @lines << c end end |
#==(e) ⇒ Object
27 28 29 30 31 |
# File 'lib/autoini/section.rb', line 27 def ==(e) e.is_a?(Section) && e.title == title && e.comment == comment && e.lines.length == lines.length && lines.map.with_index{ |l, i| e.lines[i] == l }.all? end |