Class: MobileIntent::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/mobile_intent/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, urls = {}) ⇒ Application

Returns a new instance of Application.



5
6
7
8
9
# File 'lib/mobile_intent/application.rb', line 5

def initialize(name, urls = {})
  @name = name
  @ios = urls[:ios]
  @android = urls[:android]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/mobile_intent/application.rb', line 3

def name
  @name
end

Instance Method Details

#android?Boolean

Returns:

  • (Boolean)


12
# File 'lib/mobile_intent/application.rb', line 12

def android? ; !!@android ; end

#android_intent_url(url) ⇒ Object



14
15
16
17
# File 'lib/mobile_intent/application.rb', line 14

def android_intent_url(url)
  raise unless android?
  "intent://#{url}#Intent;scheme=#{name};package=#{@android};end"
end

#android_market_urlObject



19
20
21
22
# File 'lib/mobile_intent/application.rb', line 19

def android_market_url
  raise unless android?
  "market://details?id=#{@android}"
end

#intent_url(url) ⇒ Object



33
34
35
# File 'lib/mobile_intent/application.rb', line 33

def intent_url(url)
  "#{name}://#{url}"
end

#ios?Boolean

Returns:

  • (Boolean)


11
# File 'lib/mobile_intent/application.rb', line 11

def ios? ; !!@ios ; end

#ios_market_urlObject



24
25
26
27
# File 'lib/mobile_intent/application.rb', line 24

def ios_market_url
  raise unless ios?
  "itms://itunes.com/apps/#{@ios}"
end

#launch_url(url, user_agent) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/mobile_intent/application.rb', line 37

def launch_url(url, user_agent)
  if user_agent =~ /Chrome/ && user_agent =~ /Android/
    android_intent_url(url)
  else
    intent_url(url)
  end
end

#market_url(platform) ⇒ Object



29
30
31
# File 'lib/mobile_intent/application.rb', line 29

def market_url(platform)
  send("#{platform}_market_url")
end