Class: RRTF::CharacterStyle
- Inherits:
-
Style
- Object
- AnonymousStyle
- Style
- RRTF::CharacterStyle
- Includes:
- CharacterFormatting
- Defined in:
- lib/rrtf/style/character_style.rb
Overview
This class represents a character style for an RTF document.
Constant Summary
Constants included from CharacterFormatting
RRTF::CharacterFormatting::CHARACTER_ATTRIBUTES
Instance Attribute Summary
Attributes inherited from Style
#additive, #auto_update, #based_on_style_handle, #handle, #hidden, #name, #next_style_handle, #primary, #priority
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CharacterStyle
constructor
This is the constructor for the CharacterStyle class.
-
#prefix(document) ⇒ Object
This method generates a string containing the prefix associated with the style object.
- #rtf_formatting(document) ⇒ Object
-
#to_rtf(document, options = {}) ⇒ Object
Converts the stylesheet character style into its RTF representation (for stylesheet).
Methods included from CharacterFormatting
#character_formatting_to_rtf, included, #initialize_character_formatting, #set_character_formatting_from_hashmap
Methods inherited from AnonymousStyle
#push_colours, #push_fonts, #suffix
Constructor Details
#initialize(options = {}) ⇒ CharacterStyle
This is the constructor for the CharacterStyle class.
13 14 15 16 |
# File 'lib/rrtf/style/character_style.rb', line 13 def initialize( = {}) super() initialize_character_formatting() end |
Instance Method Details
#prefix(document) ⇒ Object
This method generates a string containing the prefix associated with the style object.
50 51 52 53 54 55 56 57 |
# File 'lib/rrtf/style/character_style.rb', line 50 def prefix(document) text = StringIO.new text << "\\cs#{handle} " unless handle.nil? text << rtf_formatting(document) text.string end |
#rtf_formatting(document) ⇒ Object
59 60 61 |
# File 'lib/rrtf/style/character_style.rb', line 59 def rtf_formatting(document) character_formatting_to_rtf(document) end |
#to_rtf(document, options = {}) ⇒ Object
Converts the stylesheet character style into its RTF representation (for stylesheet)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rrtf/style/character_style.rb', line 20 def to_rtf(document, = {}) # load default options = { "uglify" => false, "base_indent" => 0 }.merge() # build formatting helpers base_prefix = ["uglify"] ? '' : ' '*["base_indent"] name_prefix = ["uglify"] ? ' ' : '' suffix = ["uglify"] ? '' : ' ' rtf = StringIO.new rtf << base_prefix rtf << "{\\*\\cs#{handle}#{suffix}" rtf << "#{rtf_formatting(document)}#{suffix}" rtf << "\\additive#{suffix}" if @additive rtf << "\\sbasedon#{@based_on_style_handle}#{suffix}" unless @based_on_style_handle.nil? rtf << "\\sautoupd#{suffix}" if @auto_update rtf << "\\snext#{@next_style_handle}#{suffix}" unless @next_style_handle.nil? rtf << "\\sqformat#{suffix}" if @primary rtf << "\\spriority#{@priority}#{suffix}" unless @priority.nil? rtf << "\\shidden#{suffix}" if @hidden rtf << "#{name_prefix}#{name};}" rtf.string end |