Class: UnderOs::UI::Image
Constant Summary
Constants included from Wrap
Wrap::INSTANCES_CACHE, Wrap::RAW_WRAPS_MAP, Wrap::WRAPS_TAGS_MAP
Instance Method Summary collapse
-
#initialize(options) ⇒ Image
constructor
A new instance of Image.
- #load(url, options = {}, &complete) ⇒ Object
- #src ⇒ Object
- #src=(src) ⇒ Object
Methods inherited from View
Methods included from Manipulation
#append, #clear, #insert, #insertTo, #prepend, #remove
Methods included from Traversing
#children, #empty?, #find, #first, #matches, #parent, #siblings
Methods included from Dimensions
#position, #position=, #size, #size=
Methods included from Animation
#animate, #fade_in, #fade_out, #highlight
Methods included from Commons
#data, #data=, #hidden, #hide, #id, #id=, #page, #show, #tagName, #toggle, #visible
Methods included from Styles
#addClass, #className, #className=, #classNames, #classNames=, #hasClass, #radioClass, #removeClass, #repaint, #style, #style=, #toggleClass
Methods included from Events
Methods included from Wrap
Constructor Details
#initialize(options) ⇒ Image
Returns a new instance of Image.
4 5 6 7 8 9 10 11 12 |
# File 'lib/under_os/ui/image.rb', line 4 def initialize() = {srs: } unless .is_a?(Hash) super() @_.contentMode = UIViewContentModeScaleAspectFit self.src = .delete(:src) if .has_key?(:src) end |
Instance Method Details
#load(url, options = {}, &complete) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/under_os/ui/image.rb', line 23 def load(url, ={}, &complete) UnderOs::HTTP.get(url, ) do |response| self.src = UIImage.imageWithData(response.data) complete.call(response) if complete && complete.arity != 0 complete.call if complete && complete.arity == 0 end end |
#src ⇒ Object
14 15 16 |
# File 'lib/under_os/ui/image.rb', line 14 def src @_.image end |
#src=(src) ⇒ Object
18 19 20 21 |
# File 'lib/under_os/ui/image.rb', line 18 def src=(src) src = UIImage.imageNamed(src) if src.is_a?(String) @_.image = src end |