Class: Dropcam::Clip

Inherits:
Object
  • Object
show all
Defined in:
lib/dropcam/clip.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(camera, properties = nil) ⇒ Clip

Returns a new instance of Clip.



7
8
9
10
# File 'lib/dropcam/clip.rb', line 7

def initialize(camera, properties = nil)
  @camera = camera
  self.properties = properties
end

Instance Attribute Details

#camera_idObject (readonly)

Returns the value of attribute camera_id.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def camera_id
  @camera_id
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def description
  @description
end

#filenameObject (readonly)

Returns the value of attribute filename.



4
5
6
# File 'lib/dropcam/clip.rb', line 4

def filename
  @filename
end

#generated_timeObject (readonly)

Returns the value of attribute generated_time.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def generated_time
  @generated_time
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def id
  @id
end

#is_errorObject (readonly)

Returns the value of attribute is_error.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def is_error
  @is_error
end

#length_in_secondsObject (readonly)

Returns the value of attribute length_in_seconds.



4
5
6
# File 'lib/dropcam/clip.rb', line 4

def length_in_seconds
  @length_in_seconds
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/dropcam/clip.rb', line 6

def properties
  @properties
end

Returns the value of attribute public_link.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def public_link
  @public_link
end

#serverObject (readonly)

Returns the value of attribute server.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def server
  @server
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def start_time
  @start_time
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/dropcam/clip.rb', line 3

def title
  @title
end

Instance Method Details

#deleteObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dropcam/clip.rb', line 39

def delete
  return false unless @id
  response = post(::CLIP_DELETE, { "id" => @id }, @cookies)      
  if response.success?
    return true
  elsif response.not_authorized?
    raise AuthorizationError 
  else 
    raise CameraNotFoundError 
  end
end


19
20
21
# File 'lib/dropcam/clip.rb', line 19

def direct_link
  return "https://#{@server}/#{@filename}"
end


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

def direct_screenshot_link
  return "https://#{@server}/s3#{File.basename(@filename, File.extname(@filename))}.jpg"
end

#set_title(title) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dropcam/clip.rb', line 26

def set_title(title)
  return false unless @id
  response = post(::CLIP_DELETE, { "id" => @id, "title" => title }, @cookies)      
  if response.success?
    return true
  elsif response.not_authorized?
    raise AuthorizationError 
  else 
    raise CameraNotFoundError 
  end
  
end