Class: TermuxRubyApi::SubSystems::Sms

Inherits:
Base
  • Object
show all
Defined in:
lib/termux_ruby_api/sub_systems/sms.rb

Instance Attribute Summary

Attributes inherited from Base

#owner

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from TermuxRubyApi::SubSystems::Base

Instance Method Details

#draft(limit: nil, offset: nil) ⇒ Array <Hash>

Returns:

  • (Array <Hash>)


72
73
74
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 72

def draft(limit: nil, offset: nil)
  list(limit: limit, offset: offset, type: :draft)
end

#draft_allArray <Hash>

Lists all the SMS messages in the draft folder of the phone, with no pagination

Returns:

  • (Array <Hash>)


78
79
80
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 78

def draft_all
  list_all(type: :draft)
end

#inbox(limit: nil, offset: nil) ⇒ Array <Hash>

Lists the SMS messages in the inbox folder of the phone

Parameters:

  • limit (Fixnum) (defaults to: nil)

    Number of messages to return

  • offset (Fixnum) (defaults to: nil)

    Start from message

Returns:

  • (Array <Hash>)


30
31
32
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 30

def inbox(limit: nil, offset: nil)
  list(limit: limit, offset: offset, type: :inbox)
end

#inbox_allArray <Hash>

Lists all the SMS messages in the inbox folder of the phone, with no pagination

Returns:

  • (Array <Hash>)


36
37
38
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 36

def inbox_all
  list_all(type: :inbox)
end

#list(limit: nil, offset: nil, type: nil) ⇒ Array <Hash>

Gets part of the list of SMS messages in the phone

Parameters:

  • limit (Fixnum) (defaults to: nil)

    Number of messages to return

  • offset (Fixnum) (defaults to: nil)

    Start from message

  • type (:inbox, :outbox, :sent) (defaults to: nil)

Returns:

  • (Array <Hash>)


9
10
11
12
13
14
15
16
17
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 9

def list(limit: nil, offset: nil, type: nil)
  args = []
  args = owner.generate_args_list([['-l', limit&.to_s],
                                   ['-o', offset&.to_s],
                                   ['-t', type]
                                  ])
  res = owner.json_api_command('sms-list', nil, *args)
  TermuxRubyApi::Utils::Xformer.xform(res, received: :time, type: :symbol)
end

#list_all(type: nil) ⇒ Array <Hash>

Lists all the SMS messages in the phone, with no pagination

Parameters:

  • type (:inbox, :outbox, :sent) (defaults to: nil)

Returns:

  • (Array <Hash>)


22
23
24
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 22

def list_all(type: nil)
  list(limit: -1, type: type)
end

#outbox(limit: nil, offset: nil) ⇒ Array <Hash>

Lists the SMS messages in the outbox folder of the phone

Parameters:

  • limit (Fixnum) (defaults to: nil)

    Number of messages to return

  • offset (Fixnum) (defaults to: nil)

    Start from message

Returns:

  • (Array <Hash>)


44
45
46
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 44

def outbox(limit: nil, offset: nil)
  list(limit: limit, offset: offset, type: :outbox)
end

#outbox_allArray <Hash>

Lists all the SMS messages in the outbox folder of the phone, with no pagination

Returns:

  • (Array <Hash>)


50
51
52
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 50

def outbox_all
  list_all(type: :outbox)
end

#send(msg, *numbers) ⇒ Object

Sends an SMS message

Parameters:

  • msg (String)

    the text of the message

  • numbers (String)

    all subsequent params are interpreted as numbers to send the message to



85
86
87
88
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 85

def send(msg, *numbers)
  args = owner.generate_args(["-n", "#{numbers.join(',')}"])
  owner.api_command('sms-send', msg, *args)
end

#sent(limit: nil, offset: nil) ⇒ Array <Hash>

Lists the SMS messages in the sent folder of the phone

Parameters:

  • limit (Fixnum) (defaults to: nil)

    Number of messages to return

  • offset (Fixnum) (defaults to: nil)

    Start from message

Returns:

  • (Array <Hash>)


58
59
60
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 58

def sent(limit: nil, offset: nil)
  list(limit: limit, offset: offset, type: :sent)
end

#sent_allArray <Hash>

Lists all the SMS messages in the sent folder of the phone, with no pagination

Returns:

  • (Array <Hash>)


64
65
66
# File 'lib/termux_ruby_api/sub_systems/sms.rb', line 64

def sent_all
  list_all(type: :sent)
end