Class: EBPS::Text::Format
- Inherits:
-
Object
- Object
- EBPS::Text::Format
- Defined in:
- lib/ebps/text/format.rb
Constant Summary collapse
- VALID_FORMATS =
%w{b i pre 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.
6 7 8 9 10 11 |
# File 'lib/ebps/text/format.rb', line 6 def initialize(*args) @values = [] augment *args @start = 0 @end = -1 end |
Instance Attribute Details
#end ⇒ Object
Returns the value of attribute end.
4 5 6 |
# File 'lib/ebps/text/format.rb', line 4 def end @end end |
#start ⇒ Object
Returns the value of attribute start.
4 5 6 |
# File 'lib/ebps/text/format.rb', line 4 def start @start end |
#values ⇒ Object
Returns the value of attribute values.
4 5 6 |
# File 'lib/ebps/text/format.rb', line 4 def values @values end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ebps/text/format.rb', line 21 def ==(other) case other when Format @values == other.values when Array @values == (other & VALID_FORMATS).sort else false end end |
#augment(*args) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/ebps/text/format.rb', line 12 def augment(*args) @values.concat(args & VALID_FORMATS) @values.sort! @values.uniq! @values end |
#range ⇒ Object
18 19 20 |
# File 'lib/ebps/text/format.rb', line 18 def range @start..@end end |