Class: Keisan::Tokens::Group
- Inherits:
-
Keisan::Token
- Object
- Keisan::Token
- Keisan::Tokens::Group
- Defined in:
- lib/keisan/tokens/group.rb
Constant Summary collapse
- REGEX =
/(\((?:[^\[\]\(\)\{\}]*+\g<1>*+)*+\)|\[(?:[^\[\]\(\)\{\}]*+\g<1>*+)*+\]|\{(?:[^\[\]\(\)\{\}]*+\g<1>*+)*+\})/
Instance Attribute Summary collapse
-
#sub_tokens ⇒ Object
readonly
Returns the value of attribute sub_tokens.
Attributes inherited from Keisan::Token
Class Method Summary collapse
Instance Method Summary collapse
-
#group_type ⇒ Object
Either :round, :square.
-
#initialize(string) ⇒ Group
constructor
A new instance of Group.
Methods inherited from Keisan::Token
Constructor Details
Instance Attribute Details
#sub_tokens ⇒ Object (readonly)
Returns the value of attribute sub_tokens.
6 7 8 |
# File 'lib/keisan/tokens/group.rb', line 6 def sub_tokens @sub_tokens end |
Class Method Details
.regex ⇒ Object
13 14 15 |
# File 'lib/keisan/tokens/group.rb', line 13 def self.regex REGEX end |
Instance Method Details
#group_type ⇒ Object
Either :round, :square
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/keisan/tokens/group.rb', line 18 def group_type case string[0] when "(" :round when "[" :square when "{" :curly end end |