Class: NRB::Untappd::API::URLTokenizer
- Inherits:
-
Object
- Object
- NRB::Untappd::API::URLTokenizer
- Defined in:
- lib/drink-socially/api/url_tokenizer.rb
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(args) ⇒ URLTokenizer
constructor
A new instance of URLTokenizer.
- #tr ⇒ Object
Constructor Details
#initialize(args) ⇒ URLTokenizer
Returns a new instance of URLTokenizer.
8 9 10 11 12 |
# File 'lib/drink-socially/api/url_tokenizer.rb', line 8 def initialize(args) @map = args[:map] @string = args[:string] raise ArgumentError unless @map && @string end |
Instance Attribute Details
#map ⇒ Object (readonly)
Returns the value of attribute map.
6 7 8 |
# File 'lib/drink-socially/api/url_tokenizer.rb', line 6 def map @map end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
6 7 8 |
# File 'lib/drink-socially/api/url_tokenizer.rb', line 6 def string @string end |
Instance Method Details
#tr ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/drink-socially/api/url_tokenizer.rb', line 15 def tr return @string unless @string =~ /:[#{word_chars}]+:/ result = "" s = StringScanner.new(@string) until s.eos? do word = s.scan(/:[#{word_chars}]+:|[#{url_chars}]+/) raise RuntimeError.new("String Scanner failed. File a bug.") if word.nil? result += tr_word(word) end result end |