Class: Interscript::DSL::Group

Inherits:
Object
  • Object
show all
Includes:
Items
Defined in:
lib/interscript/dsl/group.rb

Direct Known Subclasses

Parallel, Stage

Defined Under Namespace

Classes: Parallel

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Items

#any, #capture, #map, #maybe, #maybe_some, #method_missing, #ref, #some, #stage

Methods included from SymbolMM

#method_missing

Constructor Details

#initialize(&block) ⇒ Group

Returns a new instance of Group.



6
7
8
9
# File 'lib/interscript/dsl/group.rb', line 6

def initialize(&block)
  @node = Interscript::Node::Group.new
  self.instance_exec(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Interscript::DSL::Items

Instance Attribute Details

#nodeObject

Returns the value of attribute node.



4
5
6
# File 'lib/interscript/dsl/group.rb', line 4

def node
  @node
end

Instance Method Details

#downcaseObject



28
# File 'lib/interscript/dsl/group.rb', line 28

def downcase; :downcase; end

#parallel(**kwargs, &block) ⇒ Object



39
40
41
42
43
# File 'lib/interscript/dsl/group.rb', line 39

def parallel(**kwargs, &block)
  puts "parallel(#{chars.inspect}) from #{self.inspect}" if $DEBUG
  group = Interscript::DSL::Group::Parallel.new(**kwargs, &block)
  @node.children << group.node
end

#run(stage, **kwargs) ⇒ Object



11
12
13
14
15
16
# File 'lib/interscript/dsl/group.rb', line 11

def run(stage, **kwargs)
  if stage.class != Interscript::Node::Item::Stage
    raise Interscript::MapLogicError, "I::Node::Item::Stage expected, got #{stage.class}"
  end
  @node.children << Interscript::Node::Rule::Run.new(stage, **kwargs)
end

#sub(from, to, **kwargs, &block) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/interscript/dsl/group.rb', line 18

def sub(from, to, **kwargs, &block)
  puts "sub(#{from.inspect},#{to}, kwargs = #{
    kwargs.inspect
  }) from #{self.inspect}" if $DEBUG

  rule = Interscript::Node::Rule::Sub.new(from, to, **kwargs)
  @node.children << rule
end

#upcaseObject



27
# File 'lib/interscript/dsl/group.rb', line 27

def upcase; :upcase; end