Class: RgGen::InputBase::Item::InputMatcher
- Inherits:
-
Object
- Object
- RgGen::InputBase::Item::InputMatcher
- Defined in:
- lib/rggen/input_base/item.rb
Instance Attribute Summary collapse
-
#match_data ⇒ Object
readonly
Returns the value of attribute match_data.
Instance Method Summary collapse
-
#initialize(pattern, options) ⇒ InputMatcher
constructor
A new instance of InputMatcher.
- #match(rhs) ⇒ Object
- #match_automatically? ⇒ Boolean
Constructor Details
#initialize(pattern, options) ⇒ InputMatcher
Returns a new instance of InputMatcher.
7 8 9 10 11 12 13 14 15 |
# File 'lib/rggen/input_base/item.rb', line 7 def initialize(pattern, ) @options = @pattern = if @options.fetch(:match_wholly, true) /\A#{pattern}\z/ else pattern end end |
Instance Attribute Details
#match_data ⇒ Object (readonly)
Returns the value of attribute match_data.
17 18 19 |
# File 'lib/rggen/input_base/item.rb', line 17 def match_data @match_data end |
Instance Method Details
#match(rhs) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/rggen/input_base/item.rb', line 23 def match(rhs) rhs = rhs.to_s if @options[:convert_to_string] rhs = delete_blanks(rhs) if @options.fetch(:ignore_blank, true) @match_data = case rhs when @pattern Regexp.last_match end end |
#match_automatically? ⇒ Boolean
19 20 21 |
# File 'lib/rggen/input_base/item.rb', line 19 def match_automatically? @options.fetch(:match_automatically, true) end |