Class: RubyToBlock::Block::ControlIf
- Defined in:
- app/models/concerns/ruby_to_block/block/control_if.rb
Instance Attribute Summary
Attributes inherited from Base
#fields, #parent, #prev_sibling, #sibling, #statements, #values
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#[], #add_statement, #add_value, blocknize, indent?, #indent_level, inherited, #initialize, inline?, #inline?, #null?, priority, process_end, process_value_string, regexp, statement?, #to_xml, type, value?
Constructor Details
This class inherits a constructor from RubyToBlock::Block::Base
Class Method Details
.process_else(context) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/models/concerns/ruby_to_block/block/control_if.rb', line 27 def self.process_else(context) block = context.statement_block else_block = Block.new('null') block.add_statement(:ELSE, else_block) context.current_block = else_block true end |
.process_match_data(md, context) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/concerns/ruby_to_block/block/control_if.rb', line 7 def self.process_match_data(md, context) then_block = Block.new('null') block = new(statements: { THEN: then_block }) if context.current_block context.current_block.sibling = block else context.blocks.push(block) end md2 = regexp.match(md[type]) process_value_string(context, block, md2[1], :COND) context.current_block = then_block context.statement_stack.push([type, block]) true end |
Instance Method Details
#type ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/models/concerns/ruby_to_block/block/control_if.rb', line 36 def type if @statements.key?(:ELSE) 'control_if_else' else super end end |