Class: Verso::ExtrasList

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, HTTPGettable
Defined in:
lib/verso/extras_list.rb

Overview

Extras List resource

A collection of Extra associated with a Course framework.

Examples:

Get extras for 2012 edition of course 6320

extras = Verso::ExtrasList.new(:code => "6320", :edition => "2012")
Note:

Certain attributes are required for instantiation.

Options Hash (attrs):

  • :code (String)

    Course code Required

  • :edition (String)

    Edition year Required

See Also:

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Method Summary

Methods inherited from Base

attr_reader, #initialize

Constructor Details

This class inherits a constructor from Verso::Base

Instance Attribute Details

#codeString (readonly)

Returns Course code.

Returns:

  • (String)

    Course code



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/verso/extras_list.rb', line 20

class ExtrasList < Verso::Base
  include Enumerable
  include HTTPGettable
  extend Forwardable
  attr_reader :code, :edition
  def_delegators :extras, :[], :each, :empty?, :last, :length

private

  def extras
    @extras ||= get_attr(:extras).
      collect { |e| Extra.new(e.merge(:code => code, :edition => edition)) }
  end

  def path
    "/courses/#{code},#{edition}/extras/"
  end
end

#editionString (readonly)

Returns Edition year.

Returns:

  • (String)

    Edition year



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/verso/extras_list.rb', line 20

class ExtrasList < Verso::Base
  include Enumerable
  include HTTPGettable
  extend Forwardable
  attr_reader :code, :edition
  def_delegators :extras, :[], :each, :empty?, :last, :length

private

  def extras
    @extras ||= get_attr(:extras).
      collect { |e| Extra.new(e.merge(:code => code, :edition => edition)) }
  end

  def path
    "/courses/#{code},#{edition}/extras/"
  end
end