Class: Chronic::Sign

Inherits:
Tag
  • Object
show all
Defined in:
lib/chronic/tags/sign.rb

Direct Known Subclasses

SignMinus, SignPlus

Instance Attribute Summary

Attributes inherited from Tag

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tag

#initialize, #start=

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 Sign 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
# File 'lib/chronic/tags/sign.rb', line 11

def self.scan(tokens, options)
  tokens.each do |token|
    token.tag scan_for_plus(token)
    token.tag scan_for_minus(token)
  end
end

.scan_for_minus(token) ⇒ Object

token - The Token object we want to scan.

Returns a new SignMinus object.


28
29
30
# File 'lib/chronic/tags/sign.rb', line 28

def self.scan_for_minus(token)
  scan_for token, SignMinus, { /^-$/ => :minus }
end

.scan_for_plus(token) ⇒ Object

token - The Token object we want to scan.

Returns a new SignPlus object.


21
22
23
# File 'lib/chronic/tags/sign.rb', line 21

def self.scan_for_plus(token)
  scan_for token, SignPlus, { /^\+$/ => :plus }
end

Instance Method Details

#to_sObject


32
33
34
# File 'lib/chronic/tags/sign.rb', line 32

def to_s
  'sign'
end