Class: BerkeleyLibrary::Util::ODS::XML::Style::Style

Inherits:
ElementNode
  • Object
show all
Includes:
Comparable
Defined in:
lib/berkeley_library/util/ods/xml/style/style.rb

Direct Known Subclasses

CellStyle, ColumnStyle, RowStyle, TableStyle

Instance Attribute Summary collapse

Attributes inherited from ElementNode

#doc, #element_name, #namespace

Instance Method Summary collapse

Methods inherited from ElementNode

#add_child, #attributes, #children, #clear_attribute, #create_element, #element, #ensure_element!, #prefix, #prefixed_attr_name, #set_attribute

Constructor Details

#initialize(style_name, family, doc:) ⇒ Style

Returns a new instance of Style.



14
15
16
17
18
19
20
21
# File 'lib/berkeley_library/util/ods/xml/style/style.rb', line 14

def initialize(style_name, family, doc:)
  super(:style, 'style', doc: doc)

  @style_name = style_name
  @family = Family.ensure_family(family)

  set_default_attributes!
end

Instance Attribute Details

#familyObject (readonly)

Returns the value of attribute family.



12
13
14
# File 'lib/berkeley_library/util/ods/xml/style/style.rb', line 12

def family
  @family
end

#style_nameObject (readonly)

Returns the value of attribute style_name.



12
13
14
# File 'lib/berkeley_library/util/ods/xml/style/style.rb', line 12

def style_name
  @style_name
end

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/berkeley_library/util/ods/xml/style/style.rb', line 23

def <=>(other)
  return 0 if other.equal?(self)
  return nil unless other.instance_of?(self.class)

  s_index, o_index = [style_name, other.style_name].map { |n| family.index_part(n) }
  return style_name <=> other.style_name unless s_index && o_index

  s_index <=> o_index
end