Class: Pione::Lang::Piece

Inherits:
StructX
  • Object
show all
Includes:
Util::Positionable
Defined in:
lib/pione/lang/piece.rb

Overview

Piece is a base class for all elements of sequence. You cannot write it directly in PIONE language because pieces are not included in expressions.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Positionable

#line_and_column, #pos, #set_source_position

Class Method Details

.piece_type_name(name = nil) ⇒ Object

Declare the type name of piece.



10
11
12
# File 'lib/pione/lang/piece.rb', line 10

def self.piece_type_name(name=nil)
  name ? @piece_type_name = name : @piece_type_name
end

Instance Method Details

#eval(env) ⇒ Object



16
17
18
# File 'lib/pione/lang/piece.rb', line 16

def eval(env)
  return self
end

#textizeObject

Convert to text string.



21
22
23
24
25
26
# File 'lib/pione/lang/piece.rb', line 21

def textize
  args = to_h.map do |key, val|
    "%s=%s" % [key, val.kind_of?(Piece) ? val.textize : val.to_s]
  end.join(", ")
  "#%s{%s}" % [piece_type_name, args]
end