Class: Chronic::Separator
Direct Known Subclasses
SeparatorAnd, SeparatorAt, SeparatorColon, SeparatorComma, SeparatorDash, SeparatorDot, SeparatorIn, SeparatorOn, SeparatorQuote, SeparatorSlash, SeparatorSpace, SeparatorT, SeparatorW
Instance Attribute Summary
Attributes inherited from Tag
Class Method Summary collapse
-
.scan(tokens, options) ⇒ Object
Scan an Array of Token objects and apply any necessary Separator tags to each token.
-
.scan_for_quote(token) ⇒ Object
token - The Token object we want to scan.
Instance Method Summary collapse
Methods inherited from Tag
Constructor Details
This class inherits a constructor from Chronic::Tag
Class Method Details
.scan(tokens, options) ⇒ Object
Scan an Array of Token objects and apply any necessary Separator tags to each token.
tokens - An Array of tokens to scan. options - The Hash of options specified in Chronic::parse.
Returns an Array of tokens.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chronic/tags/separator.rb', line 11 def self.scan(tokens, ) tokens.each do |token| token.tag scan_for(token, SeparatorComma, { ','.to_sym => :comma }) token.tag scan_for(token, SeparatorDot, { '.'.to_sym => :dot }) token.tag scan_for(token, SeparatorColon, { ':'.to_sym => :colon }) token.tag scan_for(token, SeparatorSpace, { ' '.to_sym => :space }) token.tag scan_for(token, SeparatorSlash, { '/'.to_sym => :slash }) token.tag scan_for(token, SeparatorDash, { :- => :dash }) token.tag scan_for(token, SeparatorAt, { /^(at|@)$/i => :at }) token.tag scan_for(token, SeparatorIn, { 'in' => :in }) token.tag scan_for(token, SeparatorOn, { 'on' => :on }) token.tag scan_for(token, SeparatorAnd, { 'and' => :and }) token.tag scan_for(token, SeparatorT, { :T => :T }) token.tag scan_for(token, SeparatorW, { :W => :W }) token.tag scan_for_quote(token) end end |
.scan_for_quote(token) ⇒ Object
token - The Token object we want to scan.
Returns a new SeparatorQuote object.
32 33 34 35 36 37 38 |
# File 'lib/chronic/tags/separator.rb', line 32 def self.scan_for_quote(token) scan_for token, SeparatorQuote, { "'".to_sym => :single_quote, '"'.to_sym => :double_quote } end |
Instance Method Details
#to_s ⇒ Object
40 41 42 |
# File 'lib/chronic/tags/separator.rb', line 40 def to_s 'separator' end |