Class: Ramekin::Token
Instance Attribute Summary collapse
Attributes inherited from Element
#channel, #macro_stack, #start_tick
Instance Method Summary
collapse
Methods inherited from Element
make
Constructor Details
#initialize(type, *values) ⇒ Token
Returns a new instance of Token.
50
51
52
53
54
|
# File 'lib/ramekin/tokenizer.rb', line 50
def initialize(type, *values)
@type = type
@values = values
@meta = {}
end
|
Instance Attribute Details
#loc_range ⇒ Object
Returns the value of attribute loc_range.
69
70
71
|
# File 'lib/ramekin/tokenizer.rb', line 69
def loc_range
@loc_range
end
|
Returns the value of attribute meta.
68
69
70
|
# File 'lib/ramekin/tokenizer.rb', line 68
def meta
@meta
end
|
#type ⇒ Object
Returns the value of attribute type.
68
69
70
|
# File 'lib/ramekin/tokenizer.rb', line 68
def type
@type
end
|
#values ⇒ Object
Returns the value of attribute values.
68
69
70
|
# File 'lib/ramekin/tokenizer.rb', line 68
def values
@values
end
|
Instance Method Details
#components ⇒ Object
56
57
58
|
# File 'lib/ramekin/tokenizer.rb', line 56
def components
[self]
end
|
#dup ⇒ Object
64
65
66
|
# File 'lib/ramekin/tokenizer.rb', line 64
def dup
Token.new(type, *values).tap { |t| t.loc_range = loc_range }
end
|
#fin ⇒ Object
75
76
77
|
# File 'lib/ramekin/tokenizer.rb', line 75
def fin
loc_range.fin
end
|
#inspect ⇒ Object
91
92
93
|
# File 'lib/ramekin/tokenizer.rb', line 91
def inspect
"t:#{repr}"
end
|
#repr ⇒ Object
85
86
87
88
89
|
# File 'lib/ramekin/tokenizer.rb', line 85
def repr
return repr_basic if macro_stack.empty?
"#{repr_basic}[#{macro_stack.map(&:value).join(',')}]"
end
|
#repr_basic ⇒ Object
79
80
81
82
83
|
# File 'lib/ramekin/tokenizer.rb', line 79
def repr_basic
return @type if @values.empty?
"#{@type}(#{@values.join(',')})"
end
|
#start ⇒ Object
71
72
73
|
# File 'lib/ramekin/tokenizer.rb', line 71
def start
loc_range.start
end
|
#value ⇒ Object
60
61
62
|
# File 'lib/ramekin/tokenizer.rb', line 60
def value
@values[0]
end
|