Class: Jobless::Group

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Group

Returns a new instance of Group.



9
10
11
12
13
# File 'lib/group.rb', line 9

def initialize(name)
  @name = name
  @type = name.parameterize
  @items = []
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



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

def items
  @items
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#github_repo(url, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/group.rb', line 23

def github_repo(url, &block)
  repo_name = url.match(/([^\/]*)\/([^\/]*)$/).captures.join("/")
  repo_data = fetch_github_repo_data(repo_name)
  item = Item.new
  item.instance_eval do
    title repo_data['name']
    description repo_data['description']
    homepage repo_data['html_url']
  end
  item.instance_eval &block if block_given?
  @items.push item
end

#item(&block) ⇒ Object Also known as: entry



15
16
17
18
19
# File 'lib/group.rb', line 15

def item(&block)
  item = Item.new
  item.instance_eval &block
  @items.push item
end