Class: CItem
- Inherits:
-
Object
- Object
- CItem
- Defined in:
- lib/coursegen/course/data/citem.rb
Overview
Coursegen Item decorates Nanoc Item
Instance Attribute Summary collapse
-
#assigned ⇒ Object
readonly
Returns the value of attribute assigned.
-
#cat ⇒ Object
readonly
Returns the value of attribute cat.
-
#css_class ⇒ Object
readonly
Returns the value of attribute css_class.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#due ⇒ Object
readonly
Returns the value of attribute due.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#homework ⇒ Object
readonly
Returns the value of attribute homework.
-
#hwref ⇒ Object
readonly
Returns the value of attribute hwref.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#lectref ⇒ Object
readonly
Returns the value of attribute lectref.
-
#lecture_date ⇒ Object
Returns the value of attribute lecture_date.
-
#lecture_number ⇒ Object
Returns the value of attribute lecture_number.
-
#nitem ⇒ Object
readonly
Returns the value of attribute nitem.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#reading ⇒ Object
readonly
Returns the value of attribute reading.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#short_name ⇒ Object
readonly
Returns the value of attribute short_name.
-
#slides ⇒ Object
readonly
Returns the value of attribute slides.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#subsection ⇒ Object
readonly
Returns the value of attribute subsection.
-
#subsection_citem ⇒ Object
readonly
Returns the value of attribute subsection_citem.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #collapsed? ⇒ Boolean
- #hidden? ⇒ Boolean
-
#initialize(nitem = nil, ident = nil, type = nil, order = nil) ⇒ CItem
constructor
Callable with nitem=nil to create a mock.
- #lecture? ⇒ Boolean
- #lecture_date_s ⇒ Object
- #lecture_number_s ⇒ Object
- #schedule_end_date_time ⇒ Object
- #schedule_start_date_time ⇒ Object
Constructor Details
#initialize(nitem = nil, ident = nil, type = nil, order = nil) ⇒ CItem
Callable with nitem=nil to create a mock
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/coursegen/course/data/citem.rb', line 15 def initialize(nitem=nil, ident=nil, type=nil, order=nil) if !nitem.nil? # path to create a real citem fail ArgumentError, "invalid CItem contruction" unless ident.nil? @nitem = nitem defaults_from_nitem parse_identifier @nitem.identifier else # path to create a mock citem fail ArgumentError, "invalid CItem contruction" unless nitem.nil? @nitem = nil @status = nil @type = type @identifier = ident @order = order @title = ident @style = nil parse_identifier(ident) end end |
Instance Attribute Details
#assigned ⇒ Object (readonly)
Returns the value of attribute assigned.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def assigned @assigned end |
#cat ⇒ Object (readonly)
Returns the value of attribute cat.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def cat @cat end |
#css_class ⇒ Object (readonly)
Returns the value of attribute css_class.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def css_class @css_class end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def desc @desc end |
#due ⇒ Object (readonly)
Returns the value of attribute due.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def due @due end |
#end_time ⇒ Object
Returns the value of attribute end_time.
12 13 14 |
# File 'lib/coursegen/course/data/citem.rb', line 12 def end_time @end_time end |
#homework ⇒ Object (readonly)
Returns the value of attribute homework.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def homework @homework end |
#hwref ⇒ Object (readonly)
Returns the value of attribute hwref.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def hwref @hwref end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def identifier @identifier end |
#lectref ⇒ Object (readonly)
Returns the value of attribute lectref.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def lectref @lectref end |
#lecture_date ⇒ Object
Returns the value of attribute lecture_date.
12 13 14 |
# File 'lib/coursegen/course/data/citem.rb', line 12 def lecture_date @lecture_date end |
#lecture_number ⇒ Object
Returns the value of attribute lecture_number.
12 13 14 |
# File 'lib/coursegen/course/data/citem.rb', line 12 def lecture_number @lecture_number end |
#nitem ⇒ Object (readonly)
Returns the value of attribute nitem.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def nitem @nitem end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def order @order end |
#reading ⇒ Object (readonly)
Returns the value of attribute reading.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def reading @reading end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def section @section end |
#short_name ⇒ Object (readonly)
Returns the value of attribute short_name.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def short_name @short_name end |
#slides ⇒ Object (readonly)
Returns the value of attribute slides.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def @slides end |
#start_time ⇒ Object
Returns the value of attribute start_time.
12 13 14 |
# File 'lib/coursegen/course/data/citem.rb', line 12 def start_time @start_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def status @status end |
#subsection ⇒ Object (readonly)
Returns the value of attribute subsection.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def subsection @subsection end |
#subsection_citem ⇒ Object (readonly)
Returns the value of attribute subsection_citem.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def subsection_citem @subsection_citem end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/coursegen/course/data/citem.rb', line 9 def type @type end |
Instance Method Details
#collapsed? ⇒ Boolean
48 49 50 |
# File 'lib/coursegen/course/data/citem.rb', line 48 def collapsed? @collapsed = @nitem[:collapsed].nil? ? true : @nitem[:collapsed] end |
#hidden? ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/coursegen/course/data/citem.rb', line 36 def hidden? if @nitem.nil? false else @nitem[:status] == 'hidden' || %w(css min.css js pdf png).include?(@nitem[:extension]) end end |
#lecture? ⇒ Boolean
44 45 46 |
# File 'lib/coursegen/course/data/citem.rb', line 44 def lecture? !@lecture_date.nil? end |
#lecture_date_s ⇒ Object
52 53 54 |
# File 'lib/coursegen/course/data/citem.rb', line 52 def lecture_date_s @lecture_date.strftime('%a %b %-d') unless @lecture_date.nil? end |
#lecture_number_s ⇒ Object
72 73 74 |
# File 'lib/coursegen/course/data/citem.rb', line 72 def lecture_number_s "#{@section.singularize} #{@lecture_number}" end |
#schedule_end_date_time ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/coursegen/course/data/citem.rb', line 64 def schedule_end_date_time return if @lecture_date.nil? # schedule = Toc.instance.section(@section).schedule # lecture_date + schedule.end_time lecture_date + @end_time end |
#schedule_start_date_time ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/coursegen/course/data/citem.rb', line 56 def schedule_start_date_time return if @lecture_date.nil? # schedule = Toc.instance.section(@section).schedule # lecture_date + schedule.start_time lecture_date + @start_time end |