Class: Foscam::Model::FtpServer

Inherits:
Base
  • Object
show all
Includes:
Singleton
Defined in:
lib/foscam/model/ftp_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#connect, #initialize, #persisted?

Constructor Details

This class inherits a constructor from Foscam::Model::Base

Instance Attribute Details

#addressObject

Returns the value of attribute address.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def address
  @address
end

#dirObject

Returns the value of attribute dir.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def dir
  @dir
end

#passwordObject

Returns the value of attribute password.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def password
  @password
end

#portObject

Returns the value of attribute port.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def port
  @port
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def schedule
  @schedule
end

#upload_intervalObject

Returns the value of attribute upload_interval.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def upload_interval
  @upload_interval
end

#usernameObject

Returns the value of attribute username.



22
23
24
# File 'lib/foscam/model/ftp_server.rb', line 22

def username
  @username
end

Instance Method Details

#clearObject



85
86
87
88
89
90
91
92
93
# File 'lib/foscam/model/ftp_server.rb', line 85

def clear
  run_callbacks :clear do
    flag = false
    params = {:dir => "", :user => "", :pwd => "", :svr => "", :port => 21, :upload_interval => 0}
    flag = client.set_ftp(params)
    @changed_attributes.clear if flag
    flag
  end
end

#client=(obj) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/foscam/model/ftp_server.rb', line 56

def client=(obj)
  unless obj.nil?
    FtpServer::client = obj
    params = client.get_params
    unless params.empty?
      self.dir = params[:ftp_dir]
      self.address = params[:ftp_svr]
      self.port = params[:ftp_port]
      self.username = params[:ftp_user]
      self.password = params[:ftp_pwd]
      self.upload_interval = params[:ftp_upload_interval]
    end
  end
end

#saveObject



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/foscam/model/ftp_server.rb', line 73

def save
  run_callbacks :save do
    flag = false
    if changed? && is_valid?
      @previously_changed = changes
      flag = client.set_ftp(dirty_params_hash)
      @changed_attributes.clear if flag
    end
    flag
  end
end