Class: Aurum::CharacterClassDefinition
- Inherits:
-
Object
- Object
- Aurum::CharacterClassDefinition
- Defined in:
- lib/aurum/grammar.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
Instance Method Summary collapse
- #enum(a) ⇒ Object
-
#initialize ⇒ CharacterClassDefinition
constructor
A new instance of CharacterClassDefinition.
- #method_missing(name, char_set, &block) ⇒ Object
- #range(a, b) ⇒ Object
Constructor Details
#initialize ⇒ CharacterClassDefinition
Returns a new instance of CharacterClassDefinition.
14 15 16 |
# File 'lib/aurum/grammar.rb', line 14 def initialize @definitions = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, char_set, &block) ⇒ Object
30 31 32 |
# File 'lib/aurum/grammar.rb', line 30 def method_missing name, char_set, &block @definitions[name] = char_set unless @definitions.has_key? name end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
12 13 14 |
# File 'lib/aurum/grammar.rb', line 12 def definitions @definitions end |
Instance Method Details
#enum(a) ⇒ Object
24 25 26 27 28 |
# File 'lib/aurum/grammar.rb', line 24 def enum a result = CharacterSet.new result << a result end |
#range(a, b) ⇒ Object
18 19 20 21 22 |
# File 'lib/aurum/grammar.rb', line 18 def range a, b a = a[0] if a.kind_of? String b = b[0] if b.kind_of? String CharacterSet::Interval.new(a, b).to_char_set end |