Class: Learndot

Inherits:
Object
  • Object
show all
Defined in:
lib/learndot.rb,
lib/learndot/events.rb,
lib/learndot/courses.rb,
lib/learndot/training_credits.rb,
lib/learndot/learning_components.rb

Overview

This class serves as a “wrapper” for subclasses. Each time a subclass is called, it will monkeypatch itself into this one. Then you’ll have a factory method to return a properly scoped subclass.

For example:

require ‘learndot’ require ‘learndot/events’

conditions =

'startTime' => [Learndot.timestamp(), Learndot.timestamp(3*7*24*60*60)],
'status'    => ['CONFIRMED', 'TENTATIVE'],

ld = Learndot.new ld.events.retrieve(conditions)

Defined Under Namespace

Classes: API, Courses, Events, LearningComponents, TrainingCredits

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug = false, staging = false) ⇒ Learndot

Returns a new instance of Learndot.



22
23
24
# File 'lib/learndot.rb', line 22

def initialize(debug = false, staging = false)
  @api = Learndot::API.new(nil, debug, staging)
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



20
21
22
# File 'lib/learndot.rb', line 20

def api
  @api
end

Class Method Details

.timestamp(time = nil) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/learndot.rb', line 26

def self.timestamp(time = nil)
  time ||= Time.new
  time   = Time.new + time if time.is_a? Numeric
  raise "timestamp() expects a Time object or number of seconds from now as an integer." unless time.class == Time

  time.strftime('%Y-%m-%d %H:%M:%S')
end

Instance Method Details

#coursesObject



60
61
62
# File 'lib/learndot/courses.rb', line 60

def courses
  Learndot::Courses.new(self.api)
end

#eventsObject



80
81
82
# File 'lib/learndot/events.rb', line 80

def events
  Learndot::Events.new(self.api)
end

#learning_componentObject



20
21
22
# File 'lib/learndot/learning_components.rb', line 20

def learning_component
  Learndot::LearningComponents.new(self.api)
end

#training_creditsObject



28
29
30
# File 'lib/learndot/training_credits.rb', line 28

def training_credits
  Learndot::TrainingCredits.new(self.api)
end