Class: Celerity::Image
- Celerity::Element
- Celerity::Image
Included Modules
Constants
- ATTRIBUTES
- BASE_ATTRIBUTES | [:src, :alt, :longdesc, :name, :height, :width, :usemap, :ismap, :align, :border, :hspace, :vspace]
- DEFAULT_HOW
- :src
- TAGS
- [ Identifier.new('img') ]
Constants Inherited from Celerity::Element
BASE_ATTRIBUTES, CELLHALIGN_ATTRIBUTES, CELLVALIGN_ATTRIBUTES, HTML_401_TRANSITIONAL, TO_S_SIZE
Constructor Summary
This class inherits a constructor from Celerity::Element.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Celerity::Element
Dynamically get element attributes.
235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/celerity/element.rb', line 235 def method_missing(meth, *args, &blk) assert_exists meth = selector_to_attribute(meth) if self.class::ATTRIBUTES.include?(meth) || (self.class == Element && @object.hasAttribute(meth.to_s)) return @object.getAttribute(meth.to_s) end Log.warn "Element\#method_missing calling super with #{meth.inspect}" super end |
Public Visibility
Public Instance Method Summary
#file_created_date #fileCreatedDate |
returns the file created date of the image. |
---|---|
#file_size #fileSize |
returns the file size of the image in bytes. |
#height |
returns the height in pixels of the image, as a string. |
#loaded? #has_loaded? #hasLoaded? |
returns true if the image is loaded. |
#save(filename) |
Saves the image to the given file. |
#width |
returns the width in pixels of the image, as a string. |
Public Instance Methods Inherited from Celerity::Element
assert_exists, attribute_string, attribute_value, exists?, fire_event, focus, locate, methods, object, parent, respond_to?, text, to_s, to_xml, visible?, xpath
Public Instance Methods Included from Celerity::ClickableElement
click, click_and_attach, double_click, download, right_click
Public Instance Method Details
file_created_date
Also known as: fileCreatedDate
returns the file created date of the image
15 16 17 18 19 |
# File 'lib/celerity/elements/image.rb', line 15 def file_created_date assert_exists web_response = @object.getWebResponse(true) Time.parse(web_response.getResponseHeaderValue("Last-Modified").to_s) end |
file_size
Also known as: fileSize
returns the file size of the image in bytes
25 26 27 28 29 |
# File 'lib/celerity/elements/image.rb', line 25 def file_size assert_exists web_response = @object.getWebResponse(true) web_response.getContentAsBytes.length end |
height
returns the height in pixels of the image, as a string
44 45 46 47 |
# File 'lib/celerity/elements/image.rb', line 44 def height assert_exists @object.getHeight end |
loaded?
Also known as: has_loaded? hasLoaded?
returns true if the image is loaded
53 54 55 56 57 58 59 60 61 |
# File 'lib/celerity/elements/image.rb', line 53 def loaded? assert_exists begin @object.getImageReader true rescue false end end |
save
Saves the image to the given file
67 68 69 70 71 72 73 |
# File 'lib/celerity/elements/image.rb', line 67 def save(filename) assert_exists image_reader = @object.getImageReader file = java.io.File.new(filename) buffered_image = image_reader.read(0); javax.imageio.ImageIO.write(buffered_image, image_reader.getFormatName(), file); end |
width
returns the width in pixels of the image, as a string
35 36 37 38 |
# File 'lib/celerity/elements/image.rb', line 35 def width assert_exists @object.getWidth end |