Class: Hexpress::Character

Inherits:
Object show all
Defined in:
lib/hexpress/character.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, upcase = false) ⇒ Character

Returns a new instance of Character.



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hexpress/character.rb', line 4

def initialize(name, upcase = false)
  @value = case name
    when :word then '\w'
    when :digit then '\d'
    when :space then '\s'
    when :any then '.'
    when :tab then '\t'
    when :newline then '\n'
    when :return then '\r'
    else name
  end
  @upcase = upcase
end

Instance Attribute Details

#upcaseObject (readonly)

Returns the value of attribute upcase.



3
4
5
# File 'lib/hexpress/character.rb', line 3

def upcase
  @upcase
end

Instance Method Details

#to_sObject



22
23
24
# File 'lib/hexpress/character.rb', line 22

def to_s
  value
end

#valueObject



18
19
20
# File 'lib/hexpress/character.rb', line 18

def value
  if upcase then @value.upcase else @value end
end