Class: TBMX::StringToken
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StringToken.
88
89
90
91
92
|
# File 'lib/tbmx.rb', line 88
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.
86
87
88
|
# File 'lib/tbmx.rb', line 86
def text
@text
end
|
Class Method Details
.count_regex ⇒ Object
111
112
113
|
# File 'lib/tbmx.rb', line 111
def count_regex
self::COUNT_REGEX end
|
.front_match_regex ⇒ Object
107
108
109
|
# File 'lib/tbmx.rb', line 107
def front_match_regex
self::FRONT_MATCH_REGEX end
|
.full_match_regex ⇒ Object
103
104
105
|
# File 'lib/tbmx.rb', line 103
def full_match_regex
self::FULL_MATCH_REGEX end
|
.matches?(text) ⇒ Boolean
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/tbmx.rb', line 115
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
98
99
100
|
# File 'lib/tbmx.rb', line 98
def to_html
@text
end
|
#to_s ⇒ Object
94
95
96
|
# File 'lib/tbmx.rb', line 94
def to_s
@text
end
|