class Caracal::Core::Models::ParagraphModel
This class encapsulates the logic needed to store and manipulate paragraph data.
Attributes
paragraph_align[R]
paragraph_bgcolor[R]
paragraph_bold[R]
paragraph_color[R]
paragraph_italic[R]
paragraph_size[R]
paragraph_style[R]
readers
paragraph_underline[R]
Public Class Methods
new(options={}, &block)
click to toggle source
initialization
Calls superclass method
Caracal::Core::Models::BaseModel::new
# File lib/caracal/core/models/paragraph_model.rb, line 32 def initialize(options={}, &block) content = options.delete(:content) { "" } text content, options.dup, &block super options, &block end
Public Instance Methods
bookmark_end(*args, &block)
click to toggle source
# File lib/caracal/core/models/paragraph_model.rb, line 109 def bookmark_end(*args, &block) options = Caracal::Utilities.extract_options!(args) options.merge!({ start: false}) model = Caracal::Core::Models::BookmarkModel.new(options, &block) if model.valid? runs << model else raise Caracal::Errors::InvalidModelError, 'Bookmark ending tags require an id.' end model end
bookmark_start(*args, &block)
click to toggle source
.bookmarks
# File lib/caracal/core/models/paragraph_model.rb, line 97 def bookmark_start(*args, &block) options = Caracal::Utilities.extract_options!(args) options.merge!({ start: true}) model = Caracal::Core::Models::BookmarkModel.new(options, &block) if model.valid? runs << model else raise Caracal::Errors::InvalidModelError, 'Bookmark starting tags require an id and a name.' end model end
br()
click to toggle source
.br
# File lib/caracal/core/models/paragraph_model.rb, line 123 def br model = Caracal::Core::Models::LineBreakModel.new() runs << model model end
link(*args, &block)
click to toggle source
.link
# File lib/caracal/core/models/paragraph_model.rb, line 130 def link(*args, &block) options = Caracal::Utilities.extract_options!(args) options.merge!({ content: args[0] }) if args[0] options.merge!({ href: args[1] }) if args[1] model = Caracal::Core::Models::LinkModel.new(options, &block) if model.valid? runs << model else raise Caracal::Errors::InvalidModelError, ':link method must receive strings for the display text and the external href.' end model end
page()
click to toggle source
.page
# File lib/caracal/core/models/paragraph_model.rb, line 145 def page model = Caracal::Core::Models::PageBreakModel.new({ wrap: false }) runs << model model end
run_attributes()
click to toggle source
.run_attributes
# File lib/caracal/core/models/paragraph_model.rb, line 51 def run_attributes { color: paragraph_color, size: paragraph_size, bold: paragraph_bold, italic: paragraph_italic, underline: paragraph_underline, bgcolor: paragraph_bgcolor } end
runs()
click to toggle source
.runs
# File lib/caracal/core/models/paragraph_model.rb, line 46 def runs @runs ||= [] end
text(*args, &block)
click to toggle source
.text
# File lib/caracal/core/models/paragraph_model.rb, line 152 def text(*args, &block) options = Caracal::Utilities.extract_options!(args) options.merge!({ content: args.first }) if args.first model = Caracal::Core::Models::TextModel.new(options, &block) if model.valid? runs << model else raise Caracal::Errors::InvalidModelError, ':text method must receive a string for the display text.' end model end
Private Instance Methods
option_keys()
click to toggle source
# File lib/caracal/core/models/paragraph_model.rb, line 178 def option_keys [:content, :style, :align, :color, :size, :bold, :italic, :underline, :bgcolor] end