Class: Slasher::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/slasher/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContent

Returns a new instance of Content.



5
6
7
# File 'lib/slasher/content.rb', line 5

def initialize
  @collection = []
end

Instance Attribute Details

#collectionObject

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_lengthObject



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