Class: Caracal::Core::Models::ListStyleModel
- Defined in:
- lib/caracal/core/models/list_style_model.rb
Overview
This class encapsulates the logic needed to store and manipulate list style data.
Instance Attribute Summary collapse
-
#style_align ⇒ Object
readonly
Returns the value of attribute style_align.
-
#style_format ⇒ Object
readonly
Returns the value of attribute style_format.
-
#style_indent ⇒ Object
readonly
Returns the value of attribute style_indent.
-
#style_left ⇒ Object
readonly
Returns the value of attribute style_left.
-
#style_level ⇒ Object
readonly
Returns the value of attribute style_level.
-
#style_restart ⇒ Object
readonly
Returns the value of attribute style_restart.
-
#style_start ⇒ Object
readonly
Returns the value of attribute style_start.
-
#style_type ⇒ Object
readonly
accessors.
-
#style_value ⇒ Object
readonly
Returns the value of attribute style_value.
Class Method Summary collapse
-
.formatted_type(type) ⇒ Object
————————————————————- Public Class Methods ————————————————————-.
Instance Method Summary collapse
-
#formatted_type ⇒ Object
GETTERS ==============================.
-
#initialize(options = {}, &block) ⇒ ListStyleModel
constructor
initialization.
-
#matches?(type, level) ⇒ Boolean
STATE ================================.
-
#valid? ⇒ Boolean
VALIDATION ===========================.
Constructor Details
#initialize(options = {}, &block) ⇒ ListStyleModel
initialization
35 36 37 38 39 40 41 42 43 |
# File 'lib/caracal/core/models/list_style_model.rb', line 35 def initialize(={}, &block) @style_align = DEFAULT_STYLE_ALIGN @style_left = DEFAULT_STYLE_LEFT @style_indent = DEFAULT_STYLE_INDENT @style_start = DEFAULT_STYLE_START @style_restart = DEFAULT_STYLE_RESTART super , &block end |
Instance Attribute Details
#style_align ⇒ Object (readonly)
Returns the value of attribute style_align.
28 29 30 |
# File 'lib/caracal/core/models/list_style_model.rb', line 28 def style_align @style_align end |
#style_format ⇒ Object (readonly)
Returns the value of attribute style_format.
25 26 27 |
# File 'lib/caracal/core/models/list_style_model.rb', line 25 def style_format @style_format end |
#style_indent ⇒ Object (readonly)
Returns the value of attribute style_indent.
30 31 32 |
# File 'lib/caracal/core/models/list_style_model.rb', line 30 def style_indent @style_indent end |
#style_left ⇒ Object (readonly)
Returns the value of attribute style_left.
29 30 31 |
# File 'lib/caracal/core/models/list_style_model.rb', line 29 def style_left @style_left end |
#style_level ⇒ Object (readonly)
Returns the value of attribute style_level.
24 25 26 |
# File 'lib/caracal/core/models/list_style_model.rb', line 24 def style_level @style_level end |
#style_restart ⇒ Object (readonly)
Returns the value of attribute style_restart.
31 32 33 |
# File 'lib/caracal/core/models/list_style_model.rb', line 31 def style_restart @style_restart end |
#style_start ⇒ Object (readonly)
Returns the value of attribute style_start.
27 28 29 |
# File 'lib/caracal/core/models/list_style_model.rb', line 27 def style_start @style_start end |
#style_type ⇒ Object (readonly)
accessors
23 24 25 |
# File 'lib/caracal/core/models/list_style_model.rb', line 23 def style_type @style_type end |
#style_value ⇒ Object (readonly)
Returns the value of attribute style_value.
26 27 28 |
# File 'lib/caracal/core/models/list_style_model.rb', line 26 def style_value @style_value end |
Class Method Details
.formatted_type(type) ⇒ Object
Public Class Methods
50 51 52 |
# File 'lib/caracal/core/models/list_style_model.rb', line 50 def self.formatted_type(type) TYPE_MAP.fetch(type.to_s.to_sym) end |
Instance Method Details
#formatted_type ⇒ Object
GETTERS ==============================
61 62 63 |
# File 'lib/caracal/core/models/list_style_model.rb', line 61 def formatted_type self.class.formatted_type(style_type) end |
#matches?(type, level) ⇒ Boolean
STATE ================================
92 93 94 |
# File 'lib/caracal/core/models/list_style_model.rb', line 92 def matches?(type, level) style_type == type.to_s.to_sym && style_level == level.to_i end |
#valid? ⇒ Boolean
VALIDATION ===========================
99 100 101 102 |
# File 'lib/caracal/core/models/list_style_model.rb', line 99 def valid? a = [:type, :level, :format, :value] a.map { |m| send("style_#{ m }") }.compact.size == a.size end |