Class: UDRS::Components::Text
- Inherits:
-
Object
- Object
- UDRS::Components::Text
- Defined in:
- lib/udrs/components/text.rb
Constant Summary collapse
- SIZES =
%i(tiny small normal medium large huge)
- ALIGNENTS =
%i(left center right)
Instance Attribute Summary collapse
-
#alignment ⇒ Object
readonly
Returns the value of attribute alignment.
-
#is_bold ⇒ Object
readonly
Returns the value of attribute is_bold.
-
#is_italic ⇒ Object
readonly
Returns the value of attribute is_italic.
-
#is_underline ⇒ Object
readonly
Returns the value of attribute is_underline.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(text, options = {}) ⇒ Text
Returns a new instance of Text.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/udrs/components/text.rb', line 11 def initialize(text, = {}) @text = text.to_s # Text size @size = :normal @size = [:size] if [:size].present? fail ArgumentError, "Invalid size: #{@size}" unless SIZES.include?(@size) # Style(s) style = [*[:style]] @is_bold = style.delete(:bold) @is_italic = style.delete(:italic) @is_underline = style.delete(:underline) fail ArgumentError, "Invalid style(s): #{style.join(', ')}" unless style.empty? # Alignment @alignment = :left @alignment = [:align] if [:align].present? fail ArgumentError, "Invalid alignment: #{@alignment}" unless ALIGNENTS.include?(@alignment) end |
Instance Attribute Details
#alignment ⇒ Object (readonly)
Returns the value of attribute alignment.
6 7 8 |
# File 'lib/udrs/components/text.rb', line 6 def alignment @alignment end |
#is_bold ⇒ Object (readonly)
Returns the value of attribute is_bold.
6 7 8 |
# File 'lib/udrs/components/text.rb', line 6 def is_bold @is_bold end |
#is_italic ⇒ Object (readonly)
Returns the value of attribute is_italic.
6 7 8 |
# File 'lib/udrs/components/text.rb', line 6 def is_italic @is_italic end |
#is_underline ⇒ Object (readonly)
Returns the value of attribute is_underline.
6 7 8 |
# File 'lib/udrs/components/text.rb', line 6 def is_underline @is_underline end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/udrs/components/text.rb', line 6 def size @size end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/udrs/components/text.rb', line 6 def text @text end |