Class: Lexeme::Rule
- Inherits:
-
Object
- Object
- Lexeme::Rule
- Defined in:
- lib/lexeme/rule.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Instance Method Summary collapse
-
#initialize(name, regex) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(name, regex) ⇒ Rule
Returns a new instance of Rule.
5 6 7 8 9 10 11 12 13 |
# File 'lib/lexeme/rule.rb', line 5 def initialize(name, regex) raise ArgumentError, 'name must be a String or a Symbol' unless name.nil? || name.is_a?(String) || name.is_a?(Symbol) raise ArgumentError, 'regex must be a Regex' unless regex.is_a? Regexp @name = name @regex = regex end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/lexeme/rule.rb', line 3 def name @name end |
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
3 4 5 |
# File 'lib/lexeme/rule.rb', line 3 def regex @regex end |