Class: Stupidedi::Builder::LoopState

Inherits:
AbstractState show all
Defined in:
lib/stupidedi/builder/states/loop_state.rb

Instance Attribute Summary collapse

Constructors collapse

Instance Method Summary collapse

Methods inherited from AbstractState

#leaf?, lsequence, mkcomposite, mkelement, mkrepeated, mksegment, mksimple, #pretty_print, sequence, tsequence

Methods included from Inspect

#inspect

Constructor Details

#initialize(separators, segment_dict, instructions, zipper, children) ⇒ LoopState

Returns a new instance of LoopState.



23
24
25
26
# File 'lib/stupidedi/builder/states/loop_state.rb', line 23

def initialize(separators, segment_dict, instructions, zipper, children)
  @separators, @segment_dict, @instructions, @zipper, @children =
    separators, segment_dict, instructions, zipper, children
end

Instance Attribute Details

#childrenArray<AbstractState> (readonly)

Returns:



21
22
23
# File 'lib/stupidedi/builder/states/loop_state.rb', line 21

def children
  @children
end

#instructionsInstructionTable (readonly)

Returns:



15
16
17
# File 'lib/stupidedi/builder/states/loop_state.rb', line 15

def instructions
  @instructions
end

#segment_dictReader::SegmentDict (readonly)

Returns:



12
13
14
# File 'lib/stupidedi/builder/states/loop_state.rb', line 12

def segment_dict
  @segment_dict
end

#separatorsReader::Separators (readonly)

Returns:



9
10
11
# File 'lib/stupidedi/builder/states/loop_state.rb', line 9

def separators
  @separators
end

#zipperZipper::AbstractCursor (readonly)



18
19
20
# File 'lib/stupidedi/builder/states/loop_state.rb', line 18

def zipper
  @zipper
end

Class Method Details

.push(zipper, parent, segment_tok, segment_use, config) ⇒ Zipper::AbstractCursor



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/stupidedi/builder/states/loop_state.rb', line 44

def push(zipper, parent, segment_tok, segment_use, config)
  loop_def    = segment_use.parent
  loop_val    = loop_def.empty
  segment_val = mksegment(segment_tok, segment_use)

  zipper.append_child new(
    parent.separators,
    parent.segment_dict,
    parent.instructions.push(instructions(loop_def)),
    parent.zipper.append(loop_val).append_child(segment_val),
    [])
end

Instance Method Details

#copy(changes = {}) ⇒ LoopState

Returns:



29
30
31
32
33
34
35
36
# File 'lib/stupidedi/builder/states/loop_state.rb', line 29

def copy(changes = {})
  LoopState.new \
    changes.fetch(:separators, @separators),
    changes.fetch(:segment_dict, @segment_dict),
    changes.fetch(:instructions, @instructions),
    changes.fetch(:zipper, @zipper),
    changes.fetch(:children, @children)
end