Class: Caracal::Core::Models::TextModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/caracal/core/models/text_model.rb

Overview

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

Direct Known Subclasses

LinkModel

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#initialize

Constructor Details

This class inherits a constructor from Caracal::Core::Models::BaseModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



105
106
107
108
109
110
111
112
113
114
# File 'lib/caracal/core/models/text_model.rb', line 105

def method_missing(method, *args, &block)
  # I'm on the fence with respect to this implementation. We're ignoring
  # :method_missing errors to allow syntax flexibility for paragraph-type
  # models.  The issue is the syntax format of those models--the way we pass
  # the content value as a special argument--coupled with the model's
  # ability to accept nested instructions.
  #
  # By ignoring method missing errors here, we can pass the entire paragraph
  # block in the initial, built-in call to :text.
end

Instance Attribute Details

#text_bgcolorObject (readonly)

Returns the value of attribute text_bgcolor.



26
27
28
# File 'lib/caracal/core/models/text_model.rb', line 26

def text_bgcolor
  @text_bgcolor
end

#text_boldObject (readonly)

Returns the value of attribute text_bold.



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

def text_bold
  @text_bold
end

#text_colorObject (readonly)

Returns the value of attribute text_color.



21
22
23
# File 'lib/caracal/core/models/text_model.rb', line 21

def text_color
  @text_color
end

#text_contentObject (readonly)

accessors



18
19
20
# File 'lib/caracal/core/models/text_model.rb', line 18

def text_content
  @text_content
end

#text_fontObject (readonly)

Returns the value of attribute text_font.



20
21
22
# File 'lib/caracal/core/models/text_model.rb', line 20

def text_font
  @text_font
end

#text_highlight_colorObject (readonly)

Returns the value of attribute text_highlight_color.



27
28
29
# File 'lib/caracal/core/models/text_model.rb', line 27

def text_highlight_color
  @text_highlight_color
end

#text_italicObject (readonly)

Returns the value of attribute text_italic.



24
25
26
# File 'lib/caracal/core/models/text_model.rb', line 24

def text_italic
  @text_italic
end

#text_rotateObject (readonly)

Returns the value of attribute text_rotate.



29
30
31
# File 'lib/caracal/core/models/text_model.rb', line 29

def text_rotate
  @text_rotate
end

#text_sizeObject (readonly)

Returns the value of attribute text_size.



22
23
24
# File 'lib/caracal/core/models/text_model.rb', line 22

def text_size
  @text_size
end

#text_styleObject (readonly)

Returns the value of attribute text_style.



19
20
21
# File 'lib/caracal/core/models/text_model.rb', line 19

def text_style
  @text_style
end

#text_underlineObject (readonly)

Returns the value of attribute text_underline.



25
26
27
# File 'lib/caracal/core/models/text_model.rb', line 25

def text_underline
  @text_underline
end

#text_vertical_alignObject (readonly)

Returns the value of attribute text_vertical_align.



28
29
30
# File 'lib/caracal/core/models/text_model.rb', line 28

def text_vertical_align
  @text_vertical_align
end

Instance Method Details

#run_attributesObject

.run_attributes



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/caracal/core/models/text_model.rb', line 40

def run_attributes
  {
    style:            text_style,
    font:             text_font,
    color:            text_color,
    size:             text_size,
    bold:             text_bold,
    italic:           text_italic,
    underline:        text_underline,
    bgcolor:          text_bgcolor,
    highlight_color:  text_highlight_color,
    vertical_align:   text_vertical_align,
    rotate:           text_rotate
  }
end

#valid?Boolean

VALIDATION ============================

Returns:

  • (Boolean)


90
91
92
93
# File 'lib/caracal/core/models/text_model.rb', line 90

def valid?
  a = [:content]
  a.map { |m| send("text_#{ m }") }.compact.size == a.size
end