Class: Classroom

Inherits:
Object
  • Object
show all
Includes:
FirebaseCreateCommand, FirebaseUpdateCommand
Defined in:
lib/codefusion/classroom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FirebaseCreateCommand

#create

Methods included from FirebaseCommand

#classroom_codes, #get_config, #request_url, #uri

Constructor Details

#initialize(path, file) ⇒ Classroom

Returns a new instance of Classroom.



9
10
11
12
13
14
15
16
# File 'lib/codefusion/classroom.rb', line 9

def initialize(path, file)
  @path = path
  @dir = path.split('/').last
  @parent_dir = File.dirname(path)
  @code = new_code
  @file = file
  update
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/codefusion/classroom.rb', line 5

def file
  @file
end

#parent_dirObject (readonly)

Returns the value of attribute parent_dir.



5
6
7
# File 'lib/codefusion/classroom.rb', line 5

def parent_dir
  @parent_dir
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/codefusion/classroom.rb', line 5

def path
  @path
end

Instance Method Details

#updateObject



18
19
20
21
22
23
24
25
# File 'lib/codefusion/classroom.rb', line 18

def update
  request = [@code, make_hash]
  if @uuid
    FirebaseUpdateCommand.update(request, @uuid)
  else
    @uuid = set_uuid(FirebaseCreateCommand.create(request))
  end
end

#urlObject



27
28
29
# File 'lib/codefusion/classroom.rb', line 27

def url
  generate_url
end