Class: Verso::Standard

Inherits:
Base
  • Object
show all
Includes:
HTTPGettable
Defined in:
lib/verso/standard.rb

Overview

Standard resource

A standard that has been associated with a Course.

Note:

Any attributes may be set upon instantiation, using Options Hash. The following are required:

Options Hash (attrs):

  • :code (String)

    Course code Required

  • :edition (String)

    Edition year Required

  • :name (String)

    Standard name (identifier) Required

See Also:

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/verso/standard.rb', line 23

class Standard < Verso::Base
 include HTTPGettable
  attr_reader :code, :edition, :name, :title

  # @return [String] description
  def description
    get_attr(:description).to_s # sometimes nil
  end

  # @return [Array] collection of goals with #title, #description strings
  def goals
    @goals ||= get_attr(:goals).
      collect { |raw_standard| OpenStruct.new(raw_standard) }
  end


  # @return [Array] collection of contained {Verso::Standard} objects
  def sections
    @sections ||= get_attr(:sections).
      collect do |raw_section|
        Standard.new(
          raw_section.merge(:code => code, :edition => edition, :name => name)
        )
      end
  end

private

  def fetch
    super[:standard]
  end

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

#editionString (readonly)

Returns Course edition year.

Returns:

  • (String)

    Course edition year



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/verso/standard.rb', line 23

class Standard < Verso::Base
 include HTTPGettable
  attr_reader :code, :edition, :name, :title

  # @return [String] description
  def description
    get_attr(:description).to_s # sometimes nil
  end

  # @return [Array] collection of goals with #title, #description strings
  def goals
    @goals ||= get_attr(:goals).
      collect { |raw_standard| OpenStruct.new(raw_standard) }
  end


  # @return [Array] collection of contained {Verso::Standard} objects
  def sections
    @sections ||= get_attr(:sections).
      collect do |raw_section|
        Standard.new(
          raw_section.merge(:code => code, :edition => edition, :name => name)
        )
      end
  end

private

  def fetch
    super[:standard]
  end

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

#nameString (readonly)

Returns Standard name used as an identifier.

Returns:

  • (String)

    Standard name used as an identifier



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/verso/standard.rb', line 23

class Standard < Verso::Base
 include HTTPGettable
  attr_reader :code, :edition, :name, :title

  # @return [String] description
  def description
    get_attr(:description).to_s # sometimes nil
  end

  # @return [Array] collection of goals with #title, #description strings
  def goals
    @goals ||= get_attr(:goals).
      collect { |raw_standard| OpenStruct.new(raw_standard) }
  end


  # @return [Array] collection of contained {Verso::Standard} objects
  def sections
    @sections ||= get_attr(:sections).
      collect do |raw_section|
        Standard.new(
          raw_section.merge(:code => code, :edition => edition, :name => name)
        )
      end
  end

private

  def fetch
    super[:standard]
  end

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

#titleString (readonly)

Returns Standard title.

Returns:

  • (String)

    Standard title



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/verso/standard.rb', line 23

class Standard < Verso::Base
 include HTTPGettable
  attr_reader :code, :edition, :name, :title

  # @return [String] description
  def description
    get_attr(:description).to_s # sometimes nil
  end

  # @return [Array] collection of goals with #title, #description strings
  def goals
    @goals ||= get_attr(:goals).
      collect { |raw_standard| OpenStruct.new(raw_standard) }
  end


  # @return [Array] collection of contained {Verso::Standard} objects
  def sections
    @sections ||= get_attr(:sections).
      collect do |raw_section|
        Standard.new(
          raw_section.merge(:code => code, :edition => edition, :name => name)
        )
      end
  end

private

  def fetch
    super[:standard]
  end

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

Instance Method Details

#descriptionString

Returns description.

Returns:

  • (String)

    description



28
29
30
# File 'lib/verso/standard.rb', line 28

def description
  get_attr(:description).to_s # sometimes nil
end

#goalsArray

Returns collection of goals with #title, #description strings.

Returns:

  • (Array)

    collection of goals with #title, #description strings



33
34
35
36
# File 'lib/verso/standard.rb', line 33

def goals
  @goals ||= get_attr(:goals).
    collect { |raw_standard| OpenStruct.new(raw_standard) }
end

#sectionsArray

Returns collection of contained Verso::Standard objects.

Returns:



40
41
42
43
44
45
46
47
# File 'lib/verso/standard.rb', line 40

def sections
  @sections ||= get_attr(:sections).
    collect do |raw_section|
      Standard.new(
        raw_section.merge(:code => code, :edition => edition, :name => name)
      )
    end
end