Class: Fir::Lines
Instance Attribute Summary collapse
-
#members ⇒ Object
readonly
Returns the value of attribute members.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #add(n) ⇒ Object
- #blank? ⇒ Boolean
- #clone ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(*members) ⇒ Lines
constructor
A new instance of Lines.
- #join(chr = nil) ⇒ Object
- #length ⇒ Object
- #remove ⇒ Object
Constructor Details
#initialize(*members) ⇒ Lines
Returns a new instance of Lines.
9 10 11 |
# File 'lib/fir/lines.rb', line 9 def initialize(*members) @members = members end |
Instance Attribute Details
#members ⇒ Object (readonly)
Returns the value of attribute members.
7 8 9 |
# File 'lib/fir/lines.rb', line 7 def members @members end |
Class Method Details
.blank ⇒ Object
13 14 15 |
# File 'lib/fir/lines.rb', line 13 def self.blank new([]) end |
Instance Method Details
#==(other) ⇒ Object
45 46 47 |
# File 'lib/fir/lines.rb', line 45 def ==(other) other.members == members end |
#[](key) ⇒ Object
29 30 31 |
# File 'lib/fir/lines.rb', line 29 def [](key) @members[key].clone end |
#[]=(key, value) ⇒ Object
33 34 35 |
# File 'lib/fir/lines.rb', line 33 def []=(key, value) @members[key] = value end |
#add(n) ⇒ Object
49 50 51 |
# File 'lib/fir/lines.rb', line 49 def add(n) self.class.new(*(@members + [n])) end |
#blank? ⇒ Boolean
17 18 19 |
# File 'lib/fir/lines.rb', line 17 def blank? @members == [[]] end |
#clone ⇒ Object
21 22 23 |
# File 'lib/fir/lines.rb', line 21 def clone self.class.new(*@members.clone.map(&:clone)) end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/fir/lines.rb', line 25 def each(&block) @members.each(&block) end |
#join(chr = nil) ⇒ Object
41 42 43 |
# File 'lib/fir/lines.rb', line 41 def join(chr = nil) map(&:join).join(chr) end |
#length ⇒ Object
37 38 39 |
# File 'lib/fir/lines.rb', line 37 def length @members.length end |
#remove ⇒ Object
53 54 55 |
# File 'lib/fir/lines.rb', line 53 def remove self.class.new(*(@members[0...-1])) end |