Class: HackerTerm::CommentsData

Inherits:
Object
  • Object
show all
Defined in:
lib/hacker_term/comments_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CommentsData

Returns a new instance of CommentsData.



8
9
10
11
# File 'lib/hacker_term/comments_data.rb', line 8

def initialize(data)
  unescaped = CGI.unescapeHTML data
  @data = JSON.parse(unescaped)['items']
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/hacker_term/comments_data.rb', line 6

def data
  @data
end

Instance Method Details

#data_as_text(max_width) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hacker_term/comments_data.rb', line 13

def data_as_text(max_width)
  @data.each do |line|
     # words = line['comment'].split ' '
     # new_line = ''
     # words.inject(0) do |length, word| 
     #  length + word.length + 1 
     #  wor
     #  if length >= max_width
     #    length = 0 

     #  end
     # end
  end
end