Class: RRTF::Style Abstract

Inherits:
AnonymousStyle show all
Defined in:
lib/rrtf/style/style.rb

Overview

This class is abstract.

Represents an abstract style that can be applied to elements within a document AND appear in a document's stylesheet (i.e. paragraph, character, table, & section styles).

Author:

  • Wesley Hileman

  • Peter Wood

Since:

  • legacy

Direct Known Subclasses

CharacterStyle, ParagraphStyle

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AnonymousStyle

#prefix, #push_colours, #push_fonts, #rtf_formatting, #suffix

Constructor Details

#initialize(options = {}) ⇒ Style

Constructor for the style class.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • "name" (String) — default: nil

    human-readable name for the style.

  • "handle" (Integer) — default: nil

    16-bit integer that identifies the style in a document.

  • "next_style_handle" (Integer) — default: nil

    16-bit integer that identifies the next style for this style.

  • "based_on_style_handle" (Integer) — default: nil

    16-bit integer that identifies the base style for this style.

  • "priority" (Integer) — default: nil

    16-bit integer that indicates the ordering of the style among other styles in a document.

  • "primary" (Boolean) — default: false

    whether or not this style is a primary or “quick” style.

  • "additive" (Boolean) — default: false

    whether or not this character style is additive to the current paragraph style.

  • "auto_update" (Boolean) — default: false

    whether or not this style should be updated when any node to which the style is applied is updated.

  • "hidden" (Boolean) — default: false

    whether or not the style should be hidden.

Since:

  • legacy



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rrtf/style/style.rb', line 26

def initialize(options = {})
  # load default options
  options = {
    "name" => nil,
    "handle" => nil,
    "priority" => nil,
    "primary" => false,
    "additive" => false,
    "next_style_handle" => nil,
    "auto_update" => false,
    "based_on_style_handle" => nil,
    "hidden" => false
  }.merge(options)
  super(options)

  @handle = options.delete("handle")
  @name = options.delete("name")
  @priority = options.delete("priority")
  @flow = options.delete("flow")
  @primary = options.delete("primary")
  @additive = options.delete("additive")
  @next_style_handle = options.delete("next_style_handle")
  @auto_update = options.delete("auto_update")
  @hidden = options.delete("hidden")
end

Instance Attribute Details

#additiveObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def additive
  @additive
end

#auto_updateObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def auto_update
  @auto_update
end

#based_on_style_handleObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def based_on_style_handle
  @based_on_style_handle
end

#handleObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def handle
  @handle
end

#hiddenObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def hidden
  @hidden
end

#nameObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def name
  @name
end

#next_style_handleObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def next_style_handle
  @next_style_handle
end

#primaryObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def primary
  @primary
end

#priorityObject

Since:

  • legacy



10
11
12
# File 'lib/rrtf/style/style.rb', line 10

def priority
  @priority
end

Instance Method Details

#to_rtf(document) ⇒ Object

This method is abstract.

Constructs the RTF formatting representing the style in a Stylesheet. (override in derived classes as needed).

Since:

  • 0.0.1



56
57
58
# File 'lib/rrtf/style/style.rb', line 56

def to_rtf(document)
  nil
end