Module: BubbleWrap::App

Defined in:
motion/core/app.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) alert(msg, cancelButtonTitle = 'OK')



29
30
31
32
33
34
35
36
37
# File 'motion/core/app.rb', line 29

def alert(msg,cancelButtonTitle='OK')
  alert = UIAlertView.alloc.initWithTitle msg, 
    message: nil,
    delegate: nil, 
    cancelButtonTitle: cancelButtonTitle,
    otherButtonTitles: nil
  alert.show
  alert
end

+ (Object) bounds

Main Screen bounds. Useful when starting the app



81
82
83
# File 'motion/core/app.rb', line 81

def bounds
  UIScreen.mainScreen.bounds
end

+ (NSLocale) current_locale

Locale of user settings

Returns:

  • (NSLocale)

    locale of user settings



91
92
93
94
95
96
97
98
# File 'motion/core/app.rb', line 91

def current_locale
  languages = NSLocale.preferredLanguages
  if languages.count > 0
    return NSLocale.alloc.initWithLocaleIdentifier(languages.first)
  else
    return NSLocale.currentLocale
  end
end

+ (Object) delegate

Application Delegate



86
87
88
# File 'motion/core/app.rb', line 86

def delegate
  UIApplication.sharedApplication.delegate
end

+ (String) documents_path

Returns the application's document directory path where users might be able to upload content.

Returns:

  • (String)

    the path to the document directory



9
10
11
# File 'motion/core/app.rb', line 9

def documents_path
  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
end

+ (Object) frame

Return application frame



76
77
78
# File 'motion/core/app.rb', line 76

def frame
  UIScreen.mainScreen.applicationFrame
end

+ (Object) identifier



71
72
73
# File 'motion/core/app.rb', line 71

def identifier
  NSBundle.mainBundle.bundleIdentifier
end

+ (Object) name



67
68
69
# File 'motion/core/app.rb', line 67

def name
  NSBundle.mainBundle.objectForInfoDictionaryKey 'CFBundleDisplayName'
end

+ (NSNotificationCenter) notification_center

Returns the default notification center

Returns:



21
22
23
# File 'motion/core/app.rb', line 21

def notification_center
  NSNotificationCenter.defaultCenter
end

+ (Object) open_url(url)

Opens an url (string or instance of `NSURL`) in the device's web browser. Usage Example:

App.open_url("http://matt.aimonetti.net")


54
55
56
57
58
59
# File 'motion/core/app.rb', line 54

def open_url(url)
  unless url.is_a?(NSURL)
    url = NSURL.URLWithString(url)
  end
  UIApplication.sharedApplication.openURL(url)
end

+ (String) resources_path

Returns the application resource path where resource located

Returns:

  • (String)

    the application main bundle resource path



15
16
17
# File 'motion/core/app.rb', line 15

def resources_path
  NSBundle.mainBundle.resourcePath
end

+ (Object) run_after(delay, &block)

Executes a block after a certain delay Usage example:

App.run_after(0.5) {  p "It's #{Time.now}"   }


42
43
44
45
46
47
48
# File 'motion/core/app.rb', line 42

def run_after(delay,&block)
  NSTimer.scheduledTimerWithTimeInterval( delay,
                                          target: block,
                                          selector: "call:",
                                          userInfo: nil,
                                          repeats: false)
end

+ (Object) states



63
64
65
# File 'motion/core/app.rb', line 63

def states
  @states
end

+ (Object) user_cache



25
26
27
# File 'motion/core/app.rb', line 25

def user_cache
  NSUserDefaults.standardUserDefaults
end