Class: Verso::StandardsList
Overview
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
Course code.
-
#edition ⇒ String
readonly
Course edition year.
Attributes inherited from Base
Class Method Summary collapse
-
.from_course(course) ⇒ Verso::StandardsList
Find Standards by Course.
Instance Method Summary collapse
-
#non_sols ⇒ Array
Non-SOL standards in this list.
-
#sols ⇒ Array
SOL standards in this list.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Verso::Base
Instance Attribute Details
#code ⇒ String (readonly)
Returns Course code.
17 18 19 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 |
# File 'lib/verso/standards_list.rb', line 17 class StandardsList < Verso::Base include Enumerable include HTTPGettable extend Forwardable def_delegators :standards, :[], :each, :empty?, :last, :length attr_reader :code, :edition # @return [Array] Non-SOL standards in this list def non_sols @non_sols ||= reject { |s| sol_titles.include?(s.title) } end # @return [Array] SOL standards in this list def sols @sols ||= select { |s| sol_titles.include?(s.title) } end # Find Standards by {Verso::Course}. # # @param course [Verso::Course] A {Verso::Course} # @return [Verso::StandardsList] A {Verso::Course}'s standards def self.from_course(course) if course..include?("standards") StandardsList.new(:code => course.code, :edition => course.edition) else StandardsList.new(:code => course.code, :edition => course.edition, :standards => []) end end private def sol_titles ['English', 'History and Social Science', 'Mathematics', 'Science'] end def standards @standards ||= get_attr(:standards). sort_by { |s| s[:title] }. collect do |raw_standard| Standard.new(raw_standard.merge(:code => code, :edition => edition)) end end def path "/courses/#{code},#{edition}/standards/" end end |
#edition ⇒ String (readonly)
Returns Course edition year.
17 18 19 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 |
# File 'lib/verso/standards_list.rb', line 17 class StandardsList < Verso::Base include Enumerable include HTTPGettable extend Forwardable def_delegators :standards, :[], :each, :empty?, :last, :length attr_reader :code, :edition # @return [Array] Non-SOL standards in this list def non_sols @non_sols ||= reject { |s| sol_titles.include?(s.title) } end # @return [Array] SOL standards in this list def sols @sols ||= select { |s| sol_titles.include?(s.title) } end # Find Standards by {Verso::Course}. # # @param course [Verso::Course] A {Verso::Course} # @return [Verso::StandardsList] A {Verso::Course}'s standards def self.from_course(course) if course..include?("standards") StandardsList.new(:code => course.code, :edition => course.edition) else StandardsList.new(:code => course.code, :edition => course.edition, :standards => []) end end private def sol_titles ['English', 'History and Social Science', 'Mathematics', 'Science'] end def standards @standards ||= get_attr(:standards). sort_by { |s| s[:title] }. collect do |raw_standard| Standard.new(raw_standard.merge(:code => code, :edition => edition)) end end def path "/courses/#{code},#{edition}/standards/" end end |
Class Method Details
.from_course(course) ⇒ Verso::StandardsList
Find Standards by Course.
38 39 40 41 42 43 44 45 |
# File 'lib/verso/standards_list.rb', line 38 def self.from_course(course) if course..include?("standards") StandardsList.new(:code => course.code, :edition => course.edition) else StandardsList.new(:code => course.code, :edition => course.edition, :standards => []) end end |
Instance Method Details
#non_sols ⇒ Array
Returns Non-SOL standards in this list.
25 26 27 |
# File 'lib/verso/standards_list.rb', line 25 def non_sols @non_sols ||= reject { |s| sol_titles.include?(s.title) } end |
#sols ⇒ Array
Returns SOL standards in this list.
30 31 32 |
# File 'lib/verso/standards_list.rb', line 30 def sols @sols ||= select { |s| sol_titles.include?(s.title) } end |