Class: Caracal::Core::Models::ListStyleModel

Inherits:
BaseModel
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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(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

Instance Attribute Details

#style_alignObject (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_formatObject (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_indentObject (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_leftObject (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_levelObject (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_restartObject (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_startObject (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_typeObject (readonly)

accessors



23
24
25
# File 'lib/caracal/core/models/list_style_model.rb', line 23

def style_type
  @style_type
end

#style_valueObject (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_typeObject

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 ================================

Returns:

  • (Boolean)


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 ===========================

Returns:

  • (Boolean)


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