Class: Teeth::ScannerDefinition
- Inherits:
-
Object
- Object
- Teeth::ScannerDefinition
- Defined in:
- lib/teeth/scanner_definition.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, opts = {}) ⇒ ScannerDefinition
constructor
A new instance of ScannerDefinition.
- #regex_to_s ⇒ Object
- #scanner_code ⇒ Object
- #start_condition_string ⇒ Object
Constructor Details
#initialize(name, regex, opts = {}) ⇒ ScannerDefinition
Returns a new instance of ScannerDefinition.
14 15 16 17 18 19 20 |
# File 'lib/teeth/scanner_definition.rb', line 14 def initialize(name, regex, opts={}) if regex.kind_of?(Hash) regex, opts = nil, regex end @name, @regex, @start_condition = name, regex, opts[:start_condition] assert_valid_argument_combination end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/teeth/scanner_definition.rb', line 12 def name @name end |
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
12 13 14 |
# File 'lib/teeth/scanner_definition.rb', line 12 def regex @regex end |
Instance Method Details
#regex_to_s ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/teeth/scanner_definition.rb', line 26 def regex_to_s unless @regex.to_s == "" " " + @regex.to_s else "" end end |
#scanner_code ⇒ Object
22 23 24 |
# File 'lib/teeth/scanner_definition.rb', line 22 def scanner_code start_condition_string + @name.to_s + regex_to_s end |
#start_condition_string ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/teeth/scanner_definition.rb', line 34 def start_condition_string case @start_condition.to_s when /^inc/ "%s " when /^exc/ "%x " else "" end end |