Class: Slasher::Content
- Inherits:
-
Object
- Object
- Slasher::Content
- Defined in:
- lib/slasher/content.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
Instance Method Summary collapse
- #get_longest_length ⇒ Object
-
#initialize ⇒ Content
constructor
A new instance of Content.
- #push_content(content) ⇒ Object
Constructor Details
#initialize ⇒ Content
Returns a new instance of Content.
5 6 7 |
# File 'lib/slasher/content.rb', line 5 def initialize @collection = [] end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
3 4 5 |
# File 'lib/slasher/content.rb', line 3 def collection @collection end |
Instance Method Details
#get_longest_length ⇒ Object
17 18 19 20 21 |
# File 'lib/slasher/content.rb', line 17 def get_longest_length collection.sort_by do |content| content[:length] end.last end |
#push_content(content) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/slasher/content.rb', line 9 def push_content(content) stored_content = { length: content.gsub(/\s/, '').size, content: content } @collection << stored_content end |