Module: UState::Query::Narity

Included in:
And, Or
Defined in:
lib/ustate/query/narity.rb

Instance Method Summary collapse

Instance Method Details

#==(o) ⇒ Object



6
7
8
9
# File 'lib/ustate/query/narity.rb', line 6

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

#asObject



11
12
13
# File 'lib/ustate/query/narity.rb', line 11

def as
  @as
end

#as=(as) ⇒ Object



15
16
17
# File 'lib/ustate/query/narity.rb', line 15

def as=(as)
  @as = as.to_set
end

#childrenObject



19
20
21
# File 'lib/ustate/query/narity.rb', line 19

def children
  @as
end

#children=(c) ⇒ Object



23
24
25
# File 'lib/ustate/query/narity.rb', line 23

def children=(c)
  @as = c.to_set
end

#initialize(*as) ⇒ Object



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

def initialize(*as)
  @as = as.to_set
end

#inspectObject



27
28
29
# File 'lib/ustate/query/narity.rb', line 27

def inspect
  inspect_helper *@as
end

#massObject



31
32
33
34
35
# File 'lib/ustate/query/narity.rb', line 31

def mass
  @as.inject(1) do |sum, a|
    sum + (a.mass rescue 1)
  end
end

#to_sObject



37
38
39
40
41
# File 'lib/ustate/query/narity.rb', line 37

def to_s
  "(" + @as.map do |a|
    a.to_s
  end.join(" #{self.class.to_s.split("::").last.downcase} ") + ")"
end