Class: Systems::Entry
- Inherits:
-
Object
- Object
- Systems::Entry
- Includes:
- Comparable
- Defined in:
- lib/lingohub_shield/systems/entry.rb
Constant Summary collapse
- LH =
'#575757'- GREEN =
'#45cb14'- YELLOW =
'#c0cc14'- RED =
'#cc2114'- GREEN_THRESHOLD =
95- YELLOW_THRESHOLD =
90
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#font_family ⇒ Object
readonly
Returns the value of attribute font_family.
-
#font_gravity ⇒ Object
readonly
Returns the value of attribute font_gravity.
-
#font_size ⇒ Object
readonly
Returns the value of attribute font_size.
-
#font_style ⇒ Object
readonly
Returns the value of attribute font_style.
-
#font_weight ⇒ Object
readonly
Returns the value of attribute font_weight.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#percentage ⇒ Object
readonly
Returns the value of attribute percentage.
-
#stroke ⇒ Object
readonly
Returns the value of attribute stroke.
-
#stroke_width ⇒ Object
readonly
Returns the value of attribute stroke_width.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#<=>(another) ⇒ Object
enables sorting of entries alphabetically by label.
-
#background_color ⇒ Object
returns the appropriate background color depending on the percentage.
-
#initialize(label, percentage, padding = 18) ⇒ Entry
constructor
Initializes the shield entry.
Constructor Details
#initialize(label, percentage, padding = 18) ⇒ Entry
Initializes the shield entry
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lingohub_shield/systems/entry.rb', line 20 def initialize(label, percentage, padding = 18) @label = label @percentage = percentage @padding = padding @font_size = 15 @font_family = 'helvetica' @font_style = Magick::NormalStyle @font_gravity = Magick::WestGravity @stroke = 'transparent' @stroke_width = 1 @color = 'white' @width = get_text_width if percentage @font_weight = Magick::NormalWeight else @font_weight = Magick::BoldWeight end end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def color @color end |
#font_family ⇒ Object (readonly)
Returns the value of attribute font_family.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def font_family @font_family end |
#font_gravity ⇒ Object (readonly)
Returns the value of attribute font_gravity.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def font_gravity @font_gravity end |
#font_size ⇒ Object (readonly)
Returns the value of attribute font_size.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def font_size @font_size end |
#font_style ⇒ Object (readonly)
Returns the value of attribute font_style.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def font_style @font_style end |
#font_weight ⇒ Object (readonly)
Returns the value of attribute font_weight.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def font_weight @font_weight end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def label @label end |
#percentage ⇒ Object (readonly)
Returns the value of attribute percentage.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def percentage @percentage end |
#stroke ⇒ Object (readonly)
Returns the value of attribute stroke.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def stroke @stroke end |
#stroke_width ⇒ Object (readonly)
Returns the value of attribute stroke_width.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def stroke_width @stroke_width end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
14 15 16 |
# File 'lib/lingohub_shield/systems/entry.rb', line 14 def width @width end |
Instance Method Details
#<=>(another) ⇒ Object
enables sorting of entries alphabetically by label
55 56 57 |
# File 'lib/lingohub_shield/systems/entry.rb', line 55 def <=>(another) label <=> another.label end |
#background_color ⇒ Object
returns the appropriate background color depending on the percentage
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lingohub_shield/systems/entry.rb', line 42 def background_color if percentage.nil? LH elsif percentage > GREEN_THRESHOLD GREEN elsif percentage > YELLOW_THRESHOLD YELLOW else RED end end |