Module: UState::Query::Binarity

Included in:
Approximately, Equals, Greater, GreaterEqual, Less, LessEqual, NotEquals
Defined in:
lib/ustate/query/binarity.rb

Instance Method Summary collapse

Instance Method Details

#==(o) ⇒ Object



7
8
9
10
11
# File 'lib/ustate/query/binarity.rb', line 7

def ==(o)
  self.class == o.class and
  a == o.a and
  b == o.b
end

#aObject



13
14
15
# File 'lib/ustate/query/binarity.rb', line 13

def a
  @a
end

#bObject



17
18
19
# File 'lib/ustate/query/binarity.rb', line 17

def b
  @b
end

#childrenObject



21
22
23
# File 'lib/ustate/query/binarity.rb', line 21

def children
  [@a, @b]
end

#children=(c) ⇒ Object

Raises:

  • (ArgumentError)


25
26
27
28
# File 'lib/ustate/query/binarity.rb', line 25

def children=(c)
  raise ArgumentError unless c.size == 2
  @a, @b = c
end

#initialize(a, b) ⇒ Object



2
3
4
5
# File 'lib/ustate/query/binarity.rb', line 2

def initialize(a, b)
  @a = a
  @b = b
end

#inspectObject



30
31
32
# File 'lib/ustate/query/binarity.rb', line 30

def inspect
  inspect_helper @a, @b
end

#massObject



34
35
36
# File 'lib/ustate/query/binarity.rb', line 34

def mass
  1 + (@a.mass rescue 1) + (@b.mass rescue 1)
end

#to_sObject



38
39
40
# File 'lib/ustate/query/binarity.rb', line 38

def to_s
  "(#{@a} #{self.class.to_s.split('::').last.downcase} #{@b})"
end