Class: RRTF::Style

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

Overview

This is a parent class that all style classes will derive from.

Direct Known Subclasses

CharacterStyle, DocumentStyle, ParagraphStyle

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rrtf/style/style.rb', line 19

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)

  @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

Returns the value of attribute additive.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def additive
  @additive
end

#auto_updateObject

Returns the value of attribute auto_update.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def auto_update
  @auto_update
end

#based_on_style_handleObject

Returns the value of attribute based_on_style_handle.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def based_on_style_handle
  @based_on_style_handle
end

#handleObject

Returns the value of attribute handle.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def handle
  @handle
end

#hiddenObject

Returns the value of attribute hidden.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def hidden
  @hidden
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def name
  @name
end

#next_style_handleObject

Returns the value of attribute next_style_handle.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def next_style_handle
  @next_style_handle
end

#primaryObject

Returns the value of attribute primary.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def primary
  @primary
end

#priorityObject

Returns the value of attribute priority.



3
4
5
# File 'lib/rrtf/style/style.rb', line 3

def priority
  @priority
end

Instance Method Details

#is_character_style?Boolean

Used to determine if the style applies to characters. This method always returns false and should be overridden by derived classes as needed.

Returns:

  • (Boolean)


80
81
82
# File 'lib/rrtf/style/style.rb', line 80

def is_character_style?
   false
end

#is_document_style?Boolean

Used to determine if the style applies to documents. This method always returns false and should be overridden by derived classes as needed.

Returns:

  • (Boolean)


92
93
94
# File 'lib/rrtf/style/style.rb', line 92

def is_document_style?
   false
end

#is_paragraph_style?Boolean

Used to determine if the style applies to paragraphs. This method always returns false and should be overridden by derived classes as needed.

Returns:

  • (Boolean)


86
87
88
# File 'lib/rrtf/style/style.rb', line 86

def is_paragraph_style?
   false
end

#is_table_style?Boolean

Used to determine if the style applies to tables. This method always returns false and should be overridden by derived classes as needed.

Returns:

  • (Boolean)


98
99
100
# File 'lib/rrtf/style/style.rb', line 98

def is_table_style?
   false
end

#prefix(document) ⇒ Object

This method retrieves the command prefix text associated with a Style object. This method always returns nil and should be overridden by derived classes as needed.



63
64
65
# File 'lib/rrtf/style/style.rb', line 63

def prefix(document)
   nil
end

#rtf_formattingObject



67
68
69
# File 'lib/rrtf/style/style.rb', line 67

def rtf_formatting
  nil
end

#styledefObject

Constructs an RTF identifier for the style. (override in derived classes as needed)



46
47
48
# File 'lib/rrtf/style/style.rb', line 46

def styledef
  nil
end

#stylenameObject



50
51
52
# File 'lib/rrtf/style/style.rb', line 50

def stylename
  name
end

#suffix(document) ⇒ Object

This method retrieves the command suffix text associated with a Style object. This method always returns nil and should be overridden by derived classes as needed.



74
75
76
# File 'lib/rrtf/style/style.rb', line 74

def suffix(document)
   nil
end

#to_rtf(document) ⇒ Object

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



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

def to_rtf(document)
  nil
end