-
Notifications
You must be signed in to change notification settings - Fork 29
/
doc.rb
679 lines (581 loc) · 17.6 KB
/
doc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
class Store
# Returns the value of a key.
# @example
# Store['foo']
# #=> 42
def self.[](key); end
# Sets a value for a key.
# @example
# Store['foo'] = 42
def self.[]=(key, value); end
# Deletes a key from storage.
# @example
# Store.delete('foo')
def self.delete(key); end
# Returns a hash containing all the keys and values.
# @example
# Store.all
# #=> { 'foo' => 42 }
def self.all; end
end
class JSON
# Converts a JSON string into a Hash
# @param [String] string The original JSON string
# @example
# JSON.load('{"foo":"bar"}')
# #=> {"foo" => "bar"}
# @return [Hash] The hash generated from the JSON string
def self.load(string); end
end
class Object
# Converts an object to a JSON string
# @example
# {"foo" => "bar"}.to_json
# #=> '{"foo":"bar"}'
# @return [String] The JSON string generated from the object
def to_json; end
end
# @attr flex
# @attr width
# @attr height
# @attr min_width
# @attr min_height
# @attr max_width
# @attr max_height
# @attr left
# @attr right
# @attr top
# @attr bottom
# @attr padding
# @attr margin
# @attr border_width
# @attr padding_top
# @attr padding_right
# @attr padding_bottom
# @attr padding_left
# @attr padding_start
# @attr padding_end
# @attr margin_top
# @attr margin_right
# @attr margin_bottom
# @attr margin_left
# @attr margin_start
# @attr margin_end
# @attr border_top_width
# @attr border_right_width
# @attr border_bottom_width
# @attr border_left_width
# @attr border_start
# @attr border_end
# @attr name
# @attr flex_direction
# @attr justify_content
# @attr align_items
# @attr align_self
# @attr flex
# @attr flex_wrap
# @attr position_type
class CSSNode
def self.set_scale(scale); end
# Adds a new child node
# @param [CSSNode] child
def add_child(child); end
# Deletes a child node
# @param [CSSNode] child
def delete_child(child); end
# Returns an array containing the child nodes
# @return [Array<CSSNode>]
def children; end
# Returns the parent node
# @return [CSSNode]
def parent; end
# Returns the root node
# @return [CSSNode]
def root; end
end
class Base64
# Converts a string into its base64 equivalent string.
# @param [String] string The original string to be converted
# @example
# Base64.encode('xx') #=> eHg=
# @return [String] The base64 encoded string
def self.encode(string); end
# Decodes a base64 string.
# @param [String] string The base64 encoded string
# @example
# Base64.decode('eHg=') #=> xx
# @return [String] The decoded string
def self.decode(string); end
end
# See {Digest::Base Digest::Base} to see the methods implemented in subclasses:
# - {Digest::MD5 Digest::MD5}
# - {Digest::SHA1 Digest::SHA1}
# - {Digest::SHA224 Digest::SHA224}
# - {Digest::SHA256 Digest::SHA256}
# - {Digest::SHA384 Digest::SHA384}
# - {Digest::SHA512 Digest::SHA512}
module Digest
class Base
# @example
# digest = Digest::MD5.new
def initialize(algo); end
# @example
# digest.update('hello')
def update(str); end
# @example
# digest.reset
def reset; end
# @example
# digest.digest
# #=> '5d41402abc4b2a76b9719d911017c592'
def digest; end
# @example
# Digest::MD5.digest('hello')
# #=> '5d41402abc4b2a76b9719d911017c592'
def self.digest(str); end
end
class MD5 < Base; def initialize; super('MD5'); end; end
class SHA1 < Base; def initialize; super('SHA1'); end; end
class SHA224 < Base; def initialize; super('SHA224'); end; end
class SHA256 < Base; def initialize; super('SHA256'); end; end
class SHA384 < Base; def initialize; super('SHA384'); end; end
class SHA512 < Base; def initialize; super('SHA512'); end; end
end
# @attr [Float] latitude Populated by the location monitoring service
# @attr [Float] latitude Populated by the location monitoring service
# @attr [Float] longitude Populated by the location monitoring service
# @attr [Float] altitude Populated by the location monitoring service
# @attr [Time] time Populated by the location monitoring service
# @attr [Float] speed Populated by the location monitoring service
# @attr [Float] accuracy Populated by the location monitoring service
#
# @attr [String] name Populated after reverse geocoding a string
# @attr [String] address Populated after reverse geocoding a string
# @attr [String] localiton Populated after reverse geocoding a string
# @attr [String] postal_code Populated after reverse geocoding a string
# @attr [String] sub_area Populated after reverse geocoding a string
# @attr [String] area Populated after reverse geocoding a string
# @attr [String] country Populated after reverse geocoding a string
class Location
# Checks if the location service is accessible
# @example
# Location.monitor_enabled? # => true or false
def self.monitor_enabled?; end
# Starts monitoring for location updates.
#
# @param [Hash] options
# @option options [Fixnum] :distance_filter The distance in meters from the
# previous location that should trigger a monitor update.
#
# @return [Monitor]
#
# @example
# monitor = Location.monitor do |location, err|
# if location
# puts location.latitude, location.longitude
# else
# puts err
# end
# end
def self.monitor(options={}, &block); end
# Checks if the geocoder service is accessible
# @return [Boolean]
def self.geocode_enabled?; end
# Reverse geocode a string
# @example
# Location.geocode('apple inc') do |location, err|
# if location
# puts location.address
# else
# puts err
# end
# end
def self.geocode(str, &block); end
def geocode(&block); end
end
module Net
class Request
def initialize(url, options = {}, session = nil); end
def run(&callback); end
end
class Session
attr_reader :authorization
def initialize(base_url, &block); end
def self.build(base_url, &block); end
# Sets a key/value pair header to be used in all requests in this session
# @param [String] field
# @param [String] value
# @example
# session.header("Content-Type", "application/json")
def header(field, value); end
# Returns a hash containing key/value pairs of headers
# @return [Hash]
# @example
# response.headers
# #=> { 'Content-Type' => 'application/json' }
def headers; end
# Sets the Basic authentication data to be used in all requests
# @param [Hash] options
# @option options [String] user
# @option options [String] password
# @option options [String] token
def authorize(options); end
end
class Response
# @!visibility private
attr_accessor :options, :mock
# @!visibility private
def initialize(options = {}); end
# Returns the HTTP status code of the response
# @return [Fixnum]
# @example
# response.status_code
# #=> 200
def status; end
# Returns the HTTP status message of the response according to RFC 2616
# @return [String]
# @example
# response.status_message
# #=> "OK"
def status_message; end
# Returns the mime type of the response
# @return [String]
# @example
# repsonse.mime_type
# #=> "application/json"
def mime_type; end
# Returns body of the response
# @return [String]
# @example
# response.body
# #=> "Hello World"
def body; end
# Returns a hash containing key/value pairs of headers
# @return [Hash]
# @example
# response.headers
# #=> { 'Content-Type' => 'application/json' }
def headers; end
end
class << self
# Creates a session with common configuration
# @example
# session = Net.build('https://httpbin.org') do
# header(:content_type, :json)
# end
# session.get("/users") do |response|
# end
# session.get("/posts") do |response|
# end
def build(base_url, &block); end
# Track the reachability of a hostname
# @example
# # this block will be called each time network status is updated
# reachability = Net.reachable?("www.google.fr") do |reachable|
# if reachable
# ###
# end
# end
# # stop network reachability tracking
# reachability.stop
def reachable?(hostname = 'www.google.com', &block); end
# Stub an url to return the desired Response object
# @example
# Net.stub('www.example.com').and_return(Response.new(body:"example"))
# Net.get("www.example.com") do |response|
# response.body # example
# end
def stub(base_url); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.get(base_url, options); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.post(base_url, options); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.put(base_url, options); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.delete(base_url, options); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.patch(base_url, options); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.options(base_url, options); end
# @param [String] base_url The url to request
# @param [Hash] options
# @option options [Hash] headers
# @option options [String] body
# @option options [Fixnum] connection_timeout
# @option options [Fixnum] read_timeout
# @yield [response]
# @yieldparam [Response] response
def self.head(base_url, options); end
end
module Config
class << self
# User agent string to be used in all requests
# @return [String]
attr_accessor :user_agent
# Time in seconds to wait for a connection to be made. Default is 30 seconds.
# @return [Fixnum]
attr_accessor :connect_timeout
# Time in seconds to wait for a resource to finnish downloading. Default
# is 7 days.
# @return [Fixnum]
attr_accessor :read_timeout
end
end
end
class Task
class Timer
# Cancel a scheduled block
def stop; end
end
class Queue
# Run a block on a serial queue. Blocks will be run on the thread associated
# to the queue in sequential order. The first block will have to finish
# before the second block can run.
# @example
# q = Task.queue
# q.schedule { }
def schedule; end
# Wait for all scheduled blocks to finish on a serial queue
# @example
# q = Task.queue
# q.wait
def wait; end
end
# Schedule a block at every given interval (in seconds)
# @return [Timer]
# @example
# timer = Task.every 2.5 do
# # ...
# end
def self.every(interval, &block); end
# Schedule a block after a given interval (in seconds)
# @example
# timer = Task.after 0.5 do
# # ...
# end
def self.after(delay, &block); end
# Run a block on the main thread
# @example
# Task.main do
# # ...
# end
def self.main(&block); end
# Run a block concurrently in the background
# Blocks will be distributed among a pool of threads and may be executed in parallel.
# @example
# Task.background do
# # ...
# end
def self.background(&block); end
# Create a serial queue
# A <code>Task::Queue</code> object keeps a reference to a single thread.
# @return [Queue]]
# @example
# q = Task.queue
def self.queue; end
# Check is the method has been called from the main thread.
def self.main?; end
end
module UI
# @!parse
# # Hash keys: :left, :center, :right, :justify
# TEXT_ALIGNMENT = {}
# @return [Color]
def self.Color(color); end
# Represents a color. Can be initialized in several ways:
# - With a hex number:
# UI::Color.hex("#d2603c")
# - With RGB values:
# UI::Color.rgb(123, 200, 78)
# - Using one of the preset colors
class Color
attr_reader :proxy
end
# @param [Hash] options
# @option options [String] title The title of the alert
# @option options [String] message The message of the alert
# @option options [String] cancel The title for the Cancel button
# @option options [String] default The title of the 'default' button, usually
# the 'ok' button.
def self.alert(options={}, &block); end
# @param [Hash] font
# @option font [String] name
# @option font [Fixnum] size
# @option font [Symbol] trait :normal, :bold, :italic, :bold_italic
# @return [Font]
def self.Font(font); end
class Font
attr_reader :proxy
# @param [String] name
# @param [Fixnum] size
# @param [Symbol] trait :normal, :bold, :italic, :bold_italic
# @param [Symbol] extension: :ttf, :otf
def initialize(name, size, trait=nil, extension=:ttf); end
# Returns wether the font is italic
# @return [Boolean]
def italic?; end
# Returns wether the font is bold
# @return [Boolean]
def bold?; end
end
class Application
# Returns the singleton Application object
# @return [Application]
def instance; end
# Starts the application
def start; end
end
# @attr [Color] color
# @attr [String] title
# @attr [Image] image
# @attr [Font] font
class Button < Control
end
# @attr [String] source The name of the file of hte image to use
# @attr resize_mode See {RESIZE_MODES RESIZE_MODES} for possible values
class Image < View
# @!parse
# # Posible values for the <code>resize_mode</code> atttribute. Hash keys: :cover, :contain, :stretch
# RESIZE_MODES = {}
end
# @attr text_alignment
# @attr [Color] color
# @attr [String] text
# @attr [Font] font
class Label < View
end
# @attr [Screen] root_screen
class Navigation
# @param [Screen] root_screen The initial screen
def initialize(root_screen); end
# Returns the current screen being shown
# @return [Screen]
def screen; end
# Shows the navigation bar
def show_bar; end
# Hides the navigation bar
def hide_bar; end
# Returns wether the navigation bar is hidden
def bar_hidden?; end
# Sets the title shown in the navigation bar
# @param [String] title
def title=(title); end
# Sets the color of the navigation bar
# @param [Color] color
def bar_color=(color); end
# Pushes a screen onto the navigation stack, optionally animating the
# transition
# @param [Screen] screen
# @param [Boolean] animated
def push(screen, animated=true); end
# Pushes a screen from the navigation stack, optionally animating the
# transition
# @param [Boolean] animated
def pop(animated=true); end
end
# @attr [Navigation] navigation Returns the navigation object associated to
# this screen
class Screen
# Called after the screen has been loaded
def on_load; end
# Called after the screen is hown
def on_show; end
# Returns the root view of this screen
# @return [View]
def view; end
# Returns the patform-specific object
def proxy; end
end
# @attr text_alignment
# @attr [Color] color
# @attr secure
# @attr [String] text
# @attr [String] placeholder
# @attr [Font] font
class TextInput < Control
include Eventable
# Execute a block when a certain event happens. Possible event values:
# :on_change, :on_focus, :on_blur
def on(event, &block); end
end
# @attr border_width
# @attr [Color] border_color
# @attr [Fixnum] border_radius
# @attr [Color] background_color
# @attr [Float] alpha
class View < CSSNode
# Returns wether the view is hidden
# @return [Boolean]
def hidden?; end
# Sets the hidden state of the view
# @param [Boolean] hidden
def hidden=(hidden); end
# Update the position of the view and all its children
def update_layout; end
# Returns the platform-spegific object
def proxy; end
end
class ActivityIndicator < View
# Start animating the view
def start; end
# Stop animating the view
def stop; end
# Returns wether the indicator is currently animating
# @return [Boolean]
def animating?; end
# Set the color of the activity indicator
# @param [Color] color
def color=(color); end
end
class ListRow < View
def initialize; end
def update(data); end
end
class Eventable
def on(event, action=nil, &block); end
def trigger(event, *args); end
end
end