Class: Verso::OccupationData

Inherits:
Base
  • Object
show all
Defined in:
lib/verso/occupation_data.rb

Overview

Note:

Because an OccupationData object is created for you by other resources you should never need to instantiate one yourself.

Occupation Data

A list of occupations grouped by the Cluster/Pathway that contains them. Occupation Data is not an independent resource. It is a component of OccupationList, Course, and Emphasis.

Instance Attribute Summary

Attributes inherited from Base

#attrs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attr_reader, #initialize

Constructor Details

This class inherits a constructor from Verso::Base

Class Method Details

.find_by_slugs(cslug, pslug, slug) ⇒ Verso::OccupationData?

Find OccupationData by cluster, pathway, and occupation slugs

Examples:

Find an OccupationData for an occupation

od = Verso::OccupationData.find_by_slugs('finance', 'accounting', 'cost-analyst')
od.occupations.count # => 1
od.occupations.first.title # => 'Cost Analyst'

Parameters:

  • cslug (String)

    Cluster slug

  • pslug (String)

    Pathway slug

  • slug (String)

    Occupation slug

Returns:



41
42
43
44
45
46
47
48
49
50
# File 'lib/verso/occupation_data.rb', line 41

def self.find_by_slugs(cslug, pslug, slug)
  cluster = ClusterList.new.find { |c| c.slug== cslug }
  pathway = cluster.pathways.find { |p| p.slug == pslug }
  occupation = pathway.occupations.find { |o| o.slug == slug }
  OccupationData.new(
    { :cluster => { :title => cluster.title },
      :pathway => { :title => pathway.title },
      :occupations => [{ :title => occupation.title }] }
  )
end

Instance Method Details

#clusterVerso::Cluster

Returns Cluster (grandparent of occupations).

Returns:



16
17
18
# File 'lib/verso/occupation_data.rb', line 16

def cluster
  @cluster ||= Cluster.new(get_attr(:cluster))
end

#occupationsArray

Returns Collection of Verso::Occupation objects.

Returns:



21
22
23
# File 'lib/verso/occupation_data.rb', line 21

def occupations
  @occupations ||= get_attr(:occupations).collect { |o| Occupation.new(o) }
end

#pathwayVerso::Pathway

Returns Pathway (parent of occupations).

Returns:



26
27
28
# File 'lib/verso/occupation_data.rb', line 26

def pathway
  @pathway ||= Pathway.new(get_attr(:pathway))
end