Class: Ruleby::Ferrari::Container

Inherits:
Array
  • Object
show all
Defined in:
lib/dsl/ferrari.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind) ⇒ Container

Returns a new instance of Container.



146
147
148
# File 'lib/dsl/ferrari.rb', line 146

def initialize(kind)
  @kind = kind
end

Instance Attribute Details

#kindObject

Returns the value of attribute kind.



144
145
146
# File 'lib/dsl/ferrari.rb', line 144

def kind
  @kind
end

Instance Method Details

#and?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/dsl/ferrari.rb', line 165

def and?
  return kind == :and
end

#build(builder) ⇒ Object



150
151
152
153
154
155
156
157
158
159
# File 'lib/dsl/ferrari.rb', line 150

def build(builder)
  if self.or?
    # OrContainers are never built, they just contain containers that
    # will be transformed into AndContainers.
    raise 'Invalid Syntax'
  end
  self.each do |x|
    x.build builder
  end
end

#or?Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/dsl/ferrari.rb', line 161

def or?
  return kind == :or
end

#process_tree {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



169
170
171
172
173
174
175
176
177
# File 'lib/dsl/ferrari.rb', line 169

def process_tree(&block)
  has_or_child = false
  uniq!
  each do |c|          
    has_or_child = true if (c.process_tree(&block) or c.or?)
  end        
  yield(self) if (has_or_child)
  return has_or_child
end