Class: Gloo::Objs::Markdown
- Inherits:
-
Core::Obj
- Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::Markdown
- Defined in:
- lib/gloo/objs/data/markdown.rb
Constant Summary collapse
- KEYWORD =
'markdown'.freeze
- KEYWORD_SHORT =
'md'.freeze
Instance Attribute Summary
Attributes inherited from Core::Obj
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#line_count ⇒ Object
Get the number of lines of text.
-
#msg_page ⇒ Object
Show the markdown data in the terminal, paginated.
-
#msg_show ⇒ Object
Show the markdown data in the terminal.
-
#multiline_value? ⇒ Boolean
Does this object support multi-line values? Initially only true for scripts.
-
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
Methods inherited from Core::Obj
#add_child, #add_children_on_create?, #add_default_children, can_create?, #can_receive_message?, #child_count, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, help, inherited, #initialize, #msg_unload, #pn, #remove_child, #root?, #send_message, #set_parent, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?
Methods inherited from Core::Baseo
Constructor Details
This class inherits a constructor from Gloo::Core::Obj
Class Method Details
.messages ⇒ Object
Get a list of message names that this object receives.
59 60 61 |
# File 'lib/gloo/objs/data/markdown.rb', line 59 def self. return super + %w[show page] end |
.short_typename ⇒ Object
The short name of the object type.
26 27 28 |
# File 'lib/gloo/objs/data/markdown.rb', line 26 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
19 20 21 |
# File 'lib/gloo/objs/data/markdown.rb', line 19 def self.typename return KEYWORD end |
Instance Method Details
#line_count ⇒ Object
Get the number of lines of text.
48 49 50 |
# File 'lib/gloo/objs/data/markdown.rb', line 48 def line_count return value.split( "\n" ).count end |
#msg_page ⇒ Object
Show the markdown data in the terminal, paginated.
73 74 75 76 77 78 79 80 |
# File 'lib/gloo/objs/data/markdown.rb', line 73 def msg_page return unless self.value md = TTY::Markdown.parse self.value # pager = TTY::Pager::SystemPager.new command: 'less -R' pager = TTY::Pager.new pager.page( md ) end |
#msg_show ⇒ Object
Show the markdown data in the terminal.
66 67 68 |
# File 'lib/gloo/objs/data/markdown.rb', line 66 def msg_show puts TTY::Markdown.parse self.value end |
#multiline_value? ⇒ Boolean
Does this object support multi-line values? Initially only true for scripts.
41 42 43 |
# File 'lib/gloo/objs/data/markdown.rb', line 41 def multiline_value? return false end |
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
33 34 35 |
# File 'lib/gloo/objs/data/markdown.rb', line 33 def set_value( new_value ) self.value = new_value.to_s end |