Class: Namo::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/Namo/Row.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


18
19
20
# File 'lib/Namo/Row.rb', line 18

def eql?(other)
  other.is_a?(Row) && @row.eql?(other.to_h)
end

#hashObject



22
23
24
# File 'lib/Namo/Row.rb', line 22

def hash
  @row.hash
end

#match?(selections) ⇒ Boolean

Returns:

  • (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_hObject



41
42
43
# File 'lib/Namo/Row.rb', line 41

def to_h
  @row
end