Class: TBMX::StringToken
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StringToken.
85
86
87
88
89
|
# File 'lib/tbmx.rb', line 85
def initialize(text)
raise ArgumentError if not text.is_a? String
raise ArgumentError if not text =~ self.class.full_match_regex
@text = text
end
|
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
84
85
86
|
# File 'lib/tbmx.rb', line 84
def text
@text
end
|
Class Method Details
.count_regex ⇒ Object
104
105
106
|
# File 'lib/tbmx.rb', line 104
def count_regex
self::COUNT_REGEX end
|
.front_match_regex ⇒ Object
100
101
102
|
# File 'lib/tbmx.rb', line 100
def front_match_regex
self::FRONT_MATCH_REGEX end
|
.full_match_regex ⇒ Object
96
97
98
|
# File 'lib/tbmx.rb', line 96
def full_match_regex
self::FULL_MATCH_REGEX end
|
.matches?(text) ⇒ Boolean
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/tbmx.rb', line 108
def matches? text
if text =~ front_match_regex
count = text.index count_regex
if count.nil?
return [self.new(text), ""]
else
return [self.new(text[0 ... count]), text[count .. -1]]
end
else
return nil
end
end
|
Instance Method Details
#to_html ⇒ Object
91
92
93
|
# File 'lib/tbmx.rb', line 91
def to_html
@text
end
|