Class: 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.
-
#is_character_style? ⇒ Boolean
This method overrides the is_character_style? method inherited from the Style class to always return true.
-
#prefix(document) ⇒ Object
This method generates a string containing the prefix associated with a 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, #push_colours, #push_fonts, #set_character_formatting_from_hashmap
Methods inherited from Style
#is_document_style?, #is_paragraph_style?, #is_table_style?, #styledef, #stylename, #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
#is_character_style? ⇒ Boolean
This method overrides the is_character_style? method inherited from the Style class to always return true.
20 21 22 |
# File 'lib/rrtf/style/character_style.rb', line 20 def is_character_style? true end |
#prefix(document) ⇒ Object
This method generates a string containing the prefix associated with a style object.
56 57 58 59 60 61 62 63 |
# File 'lib/rrtf/style/character_style.rb', line 56 def prefix(document) text = StringIO.new text << "\\cs#{handle} " unless handle.nil? text << rtf_formatting(document) text.string end |
#rtf_formatting(document) ⇒ Object
65 66 67 |
# File 'lib/rrtf/style/character_style.rb', line 65 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)
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 51 52 |
# File 'lib/rrtf/style/character_style.rb', line 26 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 |