Class: Shoes::Para
- Includes:
- FontHelper
- Defined in:
- lacci/lib/shoes/drawables/para.rb
Constant Summary
Constants inherited from Drawable
Constants included from Log
Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary
Attributes inherited from Drawable
#debug_id, #destroyed, #parent
Attributes inherited from Linkable
Instance Method Summary collapse
-
#initialize(*args, **kwargs) ⇒ Para
constructor
Initializes a new instance of the
Para
drawable. -
#replace(*children) ⇒ void
Sets the paragraph text to a new value, which can include TextDrawables like em(), strong(), etc.
-
#text ⇒ String
Return the text, but not the styling, of the para's contents.
-
#text=(*children) ⇒ void
Set the paragraph text to a single String.
-
#to_s ⇒ String
Return the text but not styling from the para.
Methods included from FontHelper
#contains_number?, #parse_font
Methods inherited from Drawable
allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as
Methods included from MarginHelper
Methods included from Colors
Methods included from Log
configure_logger, #log_init, logger
Methods inherited from Linkable
#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event
Constructor Details
#initialize(*args, **kwargs) ⇒ Para
Initializes a new instance of the Para
drawable. There are different
methods to instantiate slightly different styles of Para, such as
tagline
, caption
and subtitle
. These will always be different
sizes, but may be generally styled differently for some display services.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lacci/lib/shoes/drawables/para.rb', line 43 def initialize(*args, **kwargs) if kwargs[:font] arr= parse_font(kwargs[:font]) if arr[0] != nil kwargs[:emphasis] = arr[0] end if arr[1] != nil kwargs[:font_variant] = arr[1] end if arr[2] != nil kwargs[:font_weight] = arr[2] end if arr[3] != nil kwargs[:size] = arr[3] end if arr[4] != "" kwargs[:family] = arr[4] end end # Don't pass text_children args to Drawable#initialize super(*[], **kwargs) # Text_children alternates strings and TextDrawables, so we can't just pass # it as a Shoes style. It won't serialize. update_text_children(args) create_display_drawable end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Shoes::Drawable
Instance Method Details
#replace(*children) ⇒ void
This method returns an undefined value.
Sets the paragraph text to a new value, which can include TextDrawables like em(), strong(), etc.
105 106 107 |
# File 'lacci/lib/shoes/drawables/para.rb', line 105 def replace(*children) update_text_children(children) end |
#text ⇒ String
Return the text, but not the styling, of the para's contents. For example, if the contents had strong and emphasized text, the bold and emphasized would be removed but the text would be returned.
124 125 126 |
# File 'lacci/lib/shoes/drawables/para.rb', line 124 def text @text_children.map(&:to_s).join end |
#text=(*children) ⇒ void
This method returns an undefined value.
Set the paragraph text to a single String. To use bold, italics, etc. use #replace instead.
114 115 116 |
# File 'lacci/lib/shoes/drawables/para.rb', line 114 def text=(*children) update_text_children(children) end |
#to_s ⇒ String
Return the text but not styling from the para. This is the same as #text.
132 133 134 |
# File 'lacci/lib/shoes/drawables/para.rb', line 132 def to_s self.text end |