Class: Verso::Cluster

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

Overview

Career Cluster Resource

Note:

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

Options Hash (attrs):

  • :id (Fixnum)

    Cluster id 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 Cluster code.

Returns:

  • (String)

    Cluster code



20
21
22
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verso/cluster.rb', line 20

class Cluster < Verso::Base
  include HTTPGettable
  attr_reader :code, :description, :id, :postsecondary_info

  # Return VDOE Cluster contact. The contact will respond to #name, #email,
  # and #phone, returning Strings.
  #
  # @return [OpenStruct]
  def contact
    @contact ||= OpenStruct.new(get_attr(:contact))
  end

  # Courses related to the Cluster
  #
  # @return [Verso::CourseList]
  def courses
    @courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).
                   sort_by { |c| c.title + c.edition }.
                   uniq { |c| c.code + c.edition }
  end

  # The Cluster's Pathways
  #
  # @see http://www.careertech.org/career-clusters/clusters-occupations.html
  # @see Verso::Pathway
  #
  # @return [Array]
  def pathways
    @pathways ||= get_attr(:pathways).
      collect { |p| Pathway.new(p) }
  end

  # @return [String] parameterized title
  def slug
    title.parameterize
  end

  # @return [String] Cluster title
  def title
    @title ||= attrs[:title] || attrs[:cluster][:title]
  end

private

  def fetch
    super[:cluster]
  end

  # @return [String] URI for Cluster resource
  def path
    "/clusters/#{id}"
  end
end

#descriptionString (readonly)

Returns HTML-formatted Cluster description.

Returns:

  • (String)

    HTML-formatted Cluster description



20
21
22
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verso/cluster.rb', line 20

class Cluster < Verso::Base
  include HTTPGettable
  attr_reader :code, :description, :id, :postsecondary_info

  # Return VDOE Cluster contact. The contact will respond to #name, #email,
  # and #phone, returning Strings.
  #
  # @return [OpenStruct]
  def contact
    @contact ||= OpenStruct.new(get_attr(:contact))
  end

  # Courses related to the Cluster
  #
  # @return [Verso::CourseList]
  def courses
    @courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).
                   sort_by { |c| c.title + c.edition }.
                   uniq { |c| c.code + c.edition }
  end

  # The Cluster's Pathways
  #
  # @see http://www.careertech.org/career-clusters/clusters-occupations.html
  # @see Verso::Pathway
  #
  # @return [Array]
  def pathways
    @pathways ||= get_attr(:pathways).
      collect { |p| Pathway.new(p) }
  end

  # @return [String] parameterized title
  def slug
    title.parameterize
  end

  # @return [String] Cluster title
  def title
    @title ||= attrs[:title] || attrs[:cluster][:title]
  end

private

  def fetch
    super[:cluster]
  end

  # @return [String] URI for Cluster resource
  def path
    "/clusters/#{id}"
  end
end

#idFixnum (readonly)

Returns Cluster id.

Returns:

  • (Fixnum)

    Cluster id



20
21
22
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verso/cluster.rb', line 20

class Cluster < Verso::Base
  include HTTPGettable
  attr_reader :code, :description, :id, :postsecondary_info

  # Return VDOE Cluster contact. The contact will respond to #name, #email,
  # and #phone, returning Strings.
  #
  # @return [OpenStruct]
  def contact
    @contact ||= OpenStruct.new(get_attr(:contact))
  end

  # Courses related to the Cluster
  #
  # @return [Verso::CourseList]
  def courses
    @courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).
                   sort_by { |c| c.title + c.edition }.
                   uniq { |c| c.code + c.edition }
  end

  # The Cluster's Pathways
  #
  # @see http://www.careertech.org/career-clusters/clusters-occupations.html
  # @see Verso::Pathway
  #
  # @return [Array]
  def pathways
    @pathways ||= get_attr(:pathways).
      collect { |p| Pathway.new(p) }
  end

  # @return [String] parameterized title
  def slug
    title.parameterize
  end

  # @return [String] Cluster title
  def title
    @title ||= attrs[:title] || attrs[:cluster][:title]
  end

private

  def fetch
    super[:cluster]
  end

  # @return [String] URI for Cluster resource
  def path
    "/clusters/#{id}"
  end
end

#postsecondary_infoString (readonly)

Returns HTML-formatted postsecondary preparation info.

Returns:

  • (String)

    HTML-formatted postsecondary preparation info



20
21
22
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verso/cluster.rb', line 20

class Cluster < Verso::Base
  include HTTPGettable
  attr_reader :code, :description, :id, :postsecondary_info

  # Return VDOE Cluster contact. The contact will respond to #name, #email,
  # and #phone, returning Strings.
  #
  # @return [OpenStruct]
  def contact
    @contact ||= OpenStruct.new(get_attr(:contact))
  end

  # Courses related to the Cluster
  #
  # @return [Verso::CourseList]
  def courses
    @courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).
                   sort_by { |c| c.title + c.edition }.
                   uniq { |c| c.code + c.edition }
  end

  # The Cluster's Pathways
  #
  # @see http://www.careertech.org/career-clusters/clusters-occupations.html
  # @see Verso::Pathway
  #
  # @return [Array]
  def pathways
    @pathways ||= get_attr(:pathways).
      collect { |p| Pathway.new(p) }
  end

  # @return [String] parameterized title
  def slug
    title.parameterize
  end

  # @return [String] Cluster title
  def title
    @title ||= attrs[:title] || attrs[:cluster][:title]
  end

private

  def fetch
    super[:cluster]
  end

  # @return [String] URI for Cluster resource
  def path
    "/clusters/#{id}"
  end
end

Instance Method Details

#contactOpenStruct

Return VDOE Cluster contact. The contact will respond to #name, #email, and #phone, returning Strings.

Returns:

  • (OpenStruct)


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

def contact
  @contact ||= OpenStruct.new(get_attr(:contact))
end

#coursesVerso::CourseList

Courses related to the Cluster

Returns:



35
36
37
38
39
# File 'lib/verso/cluster.rb', line 35

def courses
  @courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).
                 sort_by { |c| c.title + c.edition }.
                 uniq { |c| c.code + c.edition }
end

#pathwaysArray

The Cluster’s Pathways



47
48
49
50
# File 'lib/verso/cluster.rb', line 47

def pathways
  @pathways ||= get_attr(:pathways).
    collect { |p| Pathway.new(p) }
end

#slugString

Returns parameterized title.

Returns:

  • (String)

    parameterized title



53
54
55
# File 'lib/verso/cluster.rb', line 53

def slug
  title.parameterize
end

#titleString

Returns Cluster title.

Returns:

  • (String)

    Cluster title



58
59
60
# File 'lib/verso/cluster.rb', line 58

def title
  @title ||= attrs[:title] || attrs[:cluster][:title]
end