Class: Dusen::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/dusen/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Token

Returns a new instance of Token.



8
9
10
11
12
13
14
15
16
# File 'lib/dusen/token.rb', line 8

def initialize(*args)
  if args.length == 2
    @field, @value = args
  else
    @field = 'text'
    @value = args.first
  end
  @field = @field.to_s
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



6
7
8
# File 'lib/dusen/token.rb', line 6

def field
  @field
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/dusen/token.rb', line 6

def value
  @value
end

Instance Method Details

#text?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dusen/token.rb', line 22

def text?
  field == 'text'
end

#to_sObject



18
19
20
# File 'lib/dusen/token.rb', line 18

def to_s
  value
end