Class: Caracal::Core::Models::StyleModel
- Defined in:
- lib/caracal/core/models/style_model.rb
Overview
This class encapsulates the logic needed to store and manipulate paragraph style data.
Instance Attribute Summary collapse
-
#style_align ⇒ Object
readonly
Returns the value of attribute style_align.
-
#style_base ⇒ Object
readonly
Returns the value of attribute style_base.
-
#style_bold ⇒ Object
readonly
Returns the value of attribute style_bold.
-
#style_bottom ⇒ Object
readonly
Returns the value of attribute style_bottom.
-
#style_caps ⇒ Object
readonly
Returns the value of attribute style_caps.
-
#style_color ⇒ Object
readonly
Returns the value of attribute style_color.
-
#style_default ⇒ Object
readonly
accessors.
-
#style_font ⇒ Object
readonly
Returns the value of attribute style_font.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
-
#style_italic ⇒ Object
readonly
Returns the value of attribute style_italic.
-
#style_line ⇒ Object
readonly
Returns the value of attribute style_line.
-
#style_name ⇒ Object
readonly
Returns the value of attribute style_name.
-
#style_next ⇒ Object
readonly
Returns the value of attribute style_next.
-
#style_size ⇒ Object
readonly
Returns the value of attribute style_size.
-
#style_top ⇒ Object
readonly
Returns the value of attribute style_top.
-
#style_underline ⇒ Object
readonly
Returns the value of attribute style_underline.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ StyleModel
constructor
initialization.
-
#matches?(str) ⇒ Boolean
STATE ================================.
-
#valid? ⇒ Boolean
VALIDATION ===========================.
Constructor Details
#initialize(options = {}, &block) ⇒ StyleModel
initialization
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/caracal/core/models/style_model.rb', line 50 def initialize(={}, &block) @style_default = false @style_base = DEFAULT_STYLE_BASE @style_next = DEFAULT_STYLE_NEXT super , &block if (style_id == DEFAULT_STYLE_BASE) @style_default ||= true @style_color ||= DEFAULT_STYLE_COLOR @style_size ||= DEFAULT_STYLE_SIZE @style_bold ||= DEFAULT_STYLE_BOLD @style_italic ||= DEFAULT_STYLE_ITALIC @style_underline ||= DEFAULT_STYLE_UNDERLINE @style_caps ||= DEFAULT_STYLE_CAPS @style_align ||= DEFAULT_STYLE_ALIGN @style_top ||= DEFAULT_STYLE_TOP @style_bottom ||= DEFAULT_STYLE_BOTTOM @style_line ||= DEFAULT_STYLE_LINE end end |
Instance Attribute Details
#style_align ⇒ Object (readonly)
Returns the value of attribute style_align.
42 43 44 |
# File 'lib/caracal/core/models/style_model.rb', line 42 def style_align @style_align end |
#style_base ⇒ Object (readonly)
Returns the value of attribute style_base.
46 47 48 |
# File 'lib/caracal/core/models/style_model.rb', line 46 def style_base @style_base end |
#style_bold ⇒ Object (readonly)
Returns the value of attribute style_bold.
38 39 40 |
# File 'lib/caracal/core/models/style_model.rb', line 38 def style_bold @style_bold end |
#style_bottom ⇒ Object (readonly)
Returns the value of attribute style_bottom.
44 45 46 |
# File 'lib/caracal/core/models/style_model.rb', line 44 def style_bottom @style_bottom end |
#style_caps ⇒ Object (readonly)
Returns the value of attribute style_caps.
41 42 43 |
# File 'lib/caracal/core/models/style_model.rb', line 41 def style_caps @style_caps end |
#style_color ⇒ Object (readonly)
Returns the value of attribute style_color.
35 36 37 |
# File 'lib/caracal/core/models/style_model.rb', line 35 def style_color @style_color end |
#style_default ⇒ Object (readonly)
accessors
32 33 34 |
# File 'lib/caracal/core/models/style_model.rb', line 32 def style_default @style_default end |
#style_font ⇒ Object (readonly)
Returns the value of attribute style_font.
36 37 38 |
# File 'lib/caracal/core/models/style_model.rb', line 36 def style_font @style_font end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
33 34 35 |
# File 'lib/caracal/core/models/style_model.rb', line 33 def style_id @style_id end |
#style_italic ⇒ Object (readonly)
Returns the value of attribute style_italic.
39 40 41 |
# File 'lib/caracal/core/models/style_model.rb', line 39 def style_italic @style_italic end |
#style_line ⇒ Object (readonly)
Returns the value of attribute style_line.
45 46 47 |
# File 'lib/caracal/core/models/style_model.rb', line 45 def style_line @style_line end |
#style_name ⇒ Object (readonly)
Returns the value of attribute style_name.
34 35 36 |
# File 'lib/caracal/core/models/style_model.rb', line 34 def style_name @style_name end |
#style_next ⇒ Object (readonly)
Returns the value of attribute style_next.
47 48 49 |
# File 'lib/caracal/core/models/style_model.rb', line 47 def style_next @style_next end |
#style_size ⇒ Object (readonly)
Returns the value of attribute style_size.
37 38 39 |
# File 'lib/caracal/core/models/style_model.rb', line 37 def style_size @style_size end |
#style_top ⇒ Object (readonly)
Returns the value of attribute style_top.
43 44 45 |
# File 'lib/caracal/core/models/style_model.rb', line 43 def style_top @style_top end |
#style_underline ⇒ Object (readonly)
Returns the value of attribute style_underline.
40 41 42 |
# File 'lib/caracal/core/models/style_model.rb', line 40 def style_underline @style_underline end |
Instance Method Details
#matches?(str) ⇒ Boolean
STATE ================================
110 111 112 |
# File 'lib/caracal/core/models/style_model.rb', line 110 def matches?(str) style_id.downcase == str.to_s.downcase end |
#valid? ⇒ Boolean
VALIDATION ===========================
117 118 119 120 |
# File 'lib/caracal/core/models/style_model.rb', line 117 def valid? a = [:id, :name] a.map { |m| send("style_#{ m }") }.compact.size == a.size end |