Module: SMS::ClientMethods

Included in:
JoyzenClient, LgtClient, ParanClient, XpeedClient
Defined in:
lib/sms_client/client_methods.rb

Instance Method Summary collapse

Instance Method Details

#available?Boolean



12
13
14
# File 'lib/sms_client/client_methods.rb', line 12

def available?
  remains > 0
end

#deliver(to, msg) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/sms_client/client_methods.rb', line 33

def deliver(to, msg)
  return false unless available?
  return false unless valid_number?(to)
  return false if msg.strip.empty?

  SMS.log.info("Sending SMS to #{to}") if SMS.log
  SMS.log.info("==> #{msg}") if SMS.log
  
  true
end

#fromObject



16
17
18
# File 'lib/sms_client/client_methods.rb', line 16

def from
  @from ||= "01012345678"
end

#from=(num) ⇒ Object



19
20
21
22
23
# File 'lib/sms_client/client_methods.rb', line 19

def from=(num)
  if valid_number? num
    @from = num
  end
end

#initializeObject



3
4
5
6
7
# File 'lib/sms_client/client_methods.rb', line 3

def initialize
  @agent = WWW::Mechanize.new do |agent|
    agent.user_agent_alias = 'Windows IE 7'
  end
end

#login(id, password) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/sms_client/client_methods.rb', line 25

def (id, password)
  @id = id
  @password = password
  SMS.log.info "[Paran] Remains : #{remains} times" if SMS.log
  available?
  true
end

#remainsObject



9
10
11
# File 'lib/sms_client/client_methods.rb', line 9

def remains
  @remains ||= 0
end

#to_sObject



44
45
46
# File 'lib/sms_client/client_methods.rb', line 44

def to_s
  "#{self.class} : avaliable=#{available?}, from=#{from}, remains=#{remains}"
end