Class: RenderAsMarkdown::List
- Inherits:
-
Object
- Object
- RenderAsMarkdown::List
- Defined in:
- lib/render-as-markdown/list.rb
Instance Attribute Summary collapse
-
#list_items ⇒ Object
Returns the value of attribute list_items.
Instance Method Summary collapse
- #add_list_item(list_item) ⇒ Object (also: #<<)
-
#initialize(list_items) ⇒ List
constructor
A new instance of List.
- #render ⇒ Object (also: #to_s)
Constructor Details
#initialize(list_items) ⇒ List
Returns a new instance of List.
6 7 8 9 |
# File 'lib/render-as-markdown/list.rb', line 6 def initialize list_items # list_items will be an array @list_items = [*list_items] end |
Instance Attribute Details
#list_items ⇒ Object
Returns the value of attribute list_items.
4 5 6 |
# File 'lib/render-as-markdown/list.rb', line 4 def list_items @list_items end |
Instance Method Details
#add_list_item(list_item) ⇒ Object Also known as: <<
11 12 13 14 |
# File 'lib/render-as-markdown/list.rb', line 11 def add_list_item list_item # concat arrays list_items.concat [*list_item] end |
#render ⇒ Object Also known as: to_s
18 19 20 21 22 23 24 25 26 |
# File 'lib/render-as-markdown/list.rb', line 18 def render md = '' @list_items.each do |item| md << "- #{item.to_s}\n" end md end |