Class: Namo::Row
- Inherits:
-
Object
- Object
- Namo::Row
- Defined in:
- lib/Namo/Row.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](name) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #match?(selections) ⇒ Boolean
- #to_h ⇒ Object
Instance Method Details
#==(other) ⇒ Object
14 15 16 |
# File 'lib/Namo/Row.rb', line 14 def ==(other) other.is_a?(Row) && @row == other.to_h end |
#[](name) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/Namo/Row.rb', line 6 def [](name) if @formulae.key?(name) @formulae[name].call(self) else @row[name] end end |
#eql?(other) ⇒ Boolean
18 19 20 |
# File 'lib/Namo/Row.rb', line 18 def eql?(other) other.is_a?(Row) && @row.eql?(other.to_h) end |
#hash ⇒ Object
22 23 24 |
# File 'lib/Namo/Row.rb', line 22 def hash @row.hash end |
#match?(selections) ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/Namo/Row.rb', line 26 def match?(selections) selections.all? do |dimension, coordinate| case coordinate when Array, Range coordinate.include?(self[dimension]) when Proc coordinate.call(self[dimension]) when Regexp coordinate.match?(self[dimension].to_s) else self[dimension] == coordinate end end end |
#to_h ⇒ Object
41 42 43 |
# File 'lib/Namo/Row.rb', line 41 def to_h @row end |