Class: Twitter::Composer

Inherits:
Object
  • Object
show all
Defined in:
lib/twittermotion/composer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



25
26
27
# File 'lib/twittermotion/composer.rb', line 25

def callback
  @callback
end

#compose_controllerObject

Returns the value of attribute compose_controller.



24
25
26
# File 'lib/twittermotion/composer.rb', line 24

def compose_controller
  @compose_controller
end

#errorObject

Returns the value of attribute error.



26
27
28
# File 'lib/twittermotion/composer.rb', line 26

def error
  @error
end

#imagesObject

Returns the value of attribute images.



27
28
29
# File 'lib/twittermotion/composer.rb', line 27

def images
  @images
end

#resultObject

Returns the value of attribute result.



26
27
28
# File 'lib/twittermotion/composer.rb', line 26

def result
  @result
end

#tweetObject

Returns the value of attribute tweet.



27
28
29
# File 'lib/twittermotion/composer.rb', line 27

def tweet
  @tweet
end

#urlsObject

Returns the value of attribute urls.



27
28
29
# File 'lib/twittermotion/composer.rb', line 27

def urls
  @urls
end

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/twittermotion/composer.rb', line 15

def self.available?
  TWTweetComposeViewController.canSendTweet
end

.compose(options = {}, &block) ⇒ Object



19
20
21
22
# File 'lib/twittermotion/composer.rb', line 19

def self.compose(options = {}, &block)
  @composer = Composer.new
  @composer.compose(options, &block)
end

Instance Method Details

#cancelled?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/twittermotion/composer.rb', line 37

def cancelled?
  @result == TWTweetComposeViewControllerResultCancelled
end

#compose(options = {}, &compose_callback) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/twittermotion/composer.rb', line 93

def compose(options = {}, &compose_callback)
  self.error = nil

  self.tweet = options[:tweet] || self.tweet
  self.images = options[:images] || self.images
  self.urls = options[:urls] || self.urls

  if self.error
    Dispatch::Queue.main.async {
      compose_callback.call(self)
    }
    return
  end

  options[:animated] = true if !options.has_key? :animated
  options[:presenting_controller] ||= UIWindow.keyWindow.rootViewController

  self.callback ||= lambda { |composer|
    self.compose_controller.dismissModalViewControllerAnimated(true)
    compose_callback.call(self)
  }
  self.compose_controller.completionHandler = lambda { |result|
    self.result = result
    self.callback.call(self)
  }

  options[:presenting_controller].presentModalViewController(self.compose_controller, animated: options[:animated])
end

#done?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/twittermotion/composer.rb', line 33

def done?
  @result == TWTweetComposeViewControllerResultDone
end