Class: ODDB::Text::Format
- Inherits:
-
Object
- Object
- ODDB::Text::Format
- Defined in:
- lib/oddb/text/format.rb
Constant Summary collapse
- VALID_FORMATS =
%w{b i sub sup u}
Instance Attribute Summary collapse
-
#end ⇒ Object
Returns the value of attribute end.
-
#start ⇒ Object
Returns the value of attribute start.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #augment(*args) ⇒ Object
-
#initialize(*args) ⇒ Format
constructor
A new instance of Format.
- #range ⇒ Object
Constructor Details
#initialize(*args) ⇒ Format
Returns a new instance of Format.
9 10 11 12 13 14 |
# File 'lib/oddb/text/format.rb', line 9 def initialize(*args) @values = [] augment *args @start = 0 @end = -1 end |
Instance Attribute Details
#end ⇒ Object
Returns the value of attribute end.
7 8 9 |
# File 'lib/oddb/text/format.rb', line 7 def end @end end |
#start ⇒ Object
Returns the value of attribute start.
7 8 9 |
# File 'lib/oddb/text/format.rb', line 7 def start @start end |
#values ⇒ Object
Returns the value of attribute values.
7 8 9 |
# File 'lib/oddb/text/format.rb', line 7 def values @values end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/oddb/text/format.rb', line 24 def ==(other) case other when Format @values == other.values when Array @values == (other & VALID_FORMATS).sort else false end end |
#augment(*args) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/oddb/text/format.rb', line 15 def augment(*args) @values.concat(args & VALID_FORMATS) @values.sort! @values.uniq! @values end |
#range ⇒ Object
21 22 23 |
# File 'lib/oddb/text/format.rb', line 21 def range @start..@end end |