Class: Groups

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/groups.rb

Instance Method Summary collapse

Methods included from Utilities

#is_empty?, #make_list

Constructor Details

#initialize(html) ⇒ Groups

Returns a new instance of Groups.



6
7
8
9
# File 'lib/groups.rb', line 6

def initialize(html)
  @html = html
  parse_groups
end

Instance Method Details

#get_groupsObject

Get list of groups



12
13
14
# File 'lib/groups.rb', line 12

def get_groups
  return @group_list
end

Get group link



34
35
36
# File 'lib/groups.rb', line 34

def group_link(group)
  return group.css("a")[0]["href"]
end

#group_name(group) ⇒ Object

Get group name



29
30
31
# File 'lib/groups.rb', line 29

def group_name(group)
  return group.text
end

#parse_groupsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/groups.rb', line 16

def parse_groups
  groups = @html.css('#groups').css('.group').css('.item-title')

  @group_list = Array.new
  groups.each do |group|
    @group_list.push({
                       group_name: group_name(group),
                       group_link: group_link(group)
                     })
  end
end