Class: ODDB::Text::Format

Inherits:
Object
  • Object
show all
Includes:
OddbUri
Defined in:
lib/oddb/export/yaml.rb,
lib/oddb/text/format.rb

Constant Summary collapse

VALID_FORMATS =
%w{b i sub sup u}

Constants included from OddbUri

OddbUri::YAML_URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OddbUri

#to_yaml, #to_yaml_map, #to_yaml_type

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

#endObject

Returns the value of attribute end.



7
8
9
# File 'lib/oddb/text/format.rb', line 7

def end
  @end
end

#startObject

Returns the value of attribute start.



7
8
9
# File 'lib/oddb/text/format.rb', line 7

def start
  @start
end

#valuesObject

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

#rangeObject



21
22
23
# File 'lib/oddb/text/format.rb', line 21

def range
  @start..@end
end