Class: CItem

Inherits:
Object
  • Object
show all
Defined in:
lib/coursegen/course/data/citem.rb

Overview

Coursegen Item decorates Nanoc Item

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#assignedObject (readonly)

Returns the value of attribute assigned.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def assigned
  @assigned
end

#catObject (readonly)

Returns the value of attribute cat.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def cat
  @cat
end

#css_classObject (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

#descObject (readonly)

Returns the value of attribute desc.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def desc
  @desc
end

#dueObject (readonly)

Returns the value of attribute due.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def due
  @due
end

#end_timeObject

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

#homeworkObject (readonly)

Returns the value of attribute homework.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def homework
  @homework
end

#hwrefObject (readonly)

Returns the value of attribute hwref.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def hwref
  @hwref
end

#identifierObject (readonly)

Returns the value of attribute identifier.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def identifier
  @identifier
end

#lectrefObject (readonly)

Returns the value of attribute lectref.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def lectref
  @lectref
end

#lecture_dateObject

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_numberObject

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

#nitemObject (readonly)

Returns the value of attribute nitem.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def nitem
  @nitem
end

#orderObject (readonly)

Returns the value of attribute order.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def order
  @order
end

#readingObject (readonly)

Returns the value of attribute reading.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def reading
  @reading
end

#sectionObject (readonly)

Returns the value of attribute section.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def section
  @section
end

#short_nameObject (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

#slidesObject (readonly)

Returns the value of attribute slides.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def slides
  @slides
end

#start_timeObject

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

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def status
  @status
end

#subsectionObject (readonly)

Returns the value of attribute subsection.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def subsection
  @subsection
end

#subsection_citemObject (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

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/coursegen/course/data/citem.rb', line 9

def title
  @title
end

#typeObject (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


44
45
46
# File 'lib/coursegen/course/data/citem.rb', line 44

def lecture?
  !@lecture_date.nil?
end

#lecture_date_sObject



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_sObject



72
73
74
# File 'lib/coursegen/course/data/citem.rb', line 72

def lecture_number_s
  "#{@section.singularize} #{@lecture_number}"
end

#schedule_end_date_timeObject



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_timeObject



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