class Caracal::Core::Models::ListStyleModel

This class encapsulates the logic needed to store and manipulate list style data.

Attributes

style_align[R]
style_format[R]
style_indent[R]
style_left[R]
style_level[R]
style_restart[R]
style_start[R]
style_type[R]

accessors

style_value[R]

Public Class Methods

formatted_type(type) click to toggle source
# 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
new(options={}, &block) click to toggle source

initialization

Calls superclass method Caracal::Core::Models::BaseModel::new
# File lib/caracal/core/models/list_style_model.rb, line 35
def initialize(options={}, &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 options, &block
end

Public Instance Methods

formatted_type() click to toggle source
GETTERS ==============================
# File lib/caracal/core/models/list_style_model.rb, line 61
def formatted_type
  self.class.formatted_type(style_type)
end
matches?(type, level) click to toggle source
STATE ================================
# 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?() click to toggle source
VALIDATION ===========================
# 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

Private Instance Methods

option_keys() click to toggle source
# File lib/caracal/core/models/list_style_model.rb, line 110
def option_keys
  [:type, :level, :format, :value, :align, :left, :indent, :start]
end