Class: ContactsTxtAgent
- Inherits:
-
ContactsTxt
- Object
- ContactsTxt
- ContactsTxtAgent
- Defined in:
- lib/contacts_txt.rb
Instance Attribute Summary
Attributes inherited from ContactsTxt
Instance Method Summary collapse
Methods inherited from ContactsTxt
#all, #dx, #email_list, #find_by_id, #find_by_mobile, #find_by_name, #find_by_sms, #find_by_telno, #initialize, #list_names, #mobile_list, #multi_tel_index, #save, #to_dx
Constructor Details
This class inherits a constructor from ContactsTxt
Instance Method Details
#find_mobile_by_name(s) ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/contacts_txt.rb', line 266 def find_mobile_by_name(s) result = find_by_name(s) r = validate(result) numbers = [r.sms.empty? ? r.mobile : r.sms, r.mobile].uniq\ .map {|x| x.sub(/\([^\)]+\)/,'').strip} h = {} h[:msg] = if numbers.length > 1 then "The SMS number for %s is %s and the mobile number is %s" % \ [r.fullname, *numbers] elsif numbers.first.length > 0 then "The mobile number for %s is %s" % [r.fullname, numbers.first] elsif r.tel.length > 0 then "I don't have a mobile number, but the landline telephone " + \ "number for %s is %s" % [r.fullname, r.tel] else "I don't have a telephone number for " + r.fullname end h[:tags] = r..to_s h end |
#find_tel_by_name(s) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/contacts_txt.rb', line 292 def find_tel_by_name(s) result = find_by_name(s) r = validate(result) h = {} if r.tel.empty? then return find_mobile_by_name(s) else h[:msg] = "The telephone number for %s is %s" % [r.fullname, r.tel] end h[:tags] = r..to_s h end |