Class: SWS::Image

Inherits:
Component show all
Defined in:
lib/sws/Core/components/Image/Image.rb

Overview

Represents <IMG HTML tag Bindings:

  • src - src attribute of the tag

  • alt - alt attribute of the tag

  • resource - resource name to use as data for the image

  • framework - framework name to find the resource in

  • other_tag_string - generic string to add to the tag

Instance Attribute Summary

Attributes inherited from Component

#action_components, #definition_component, #encoding, #html_attrs, #method_to_call, #name, #parameters, #parent, #request, #request_number, #slots, #subcomponents, #tokens

Instance Method Summary collapse

Methods inherited from Component

#api_filename, #app, #awake, #content?, create, #create_component_tree, #definition_filename, #initialize, #page, #perform_action, #process_bindings, #process_parameters, #process_request, #remove_subcomponents, #session, #set_request_subcomponents, #sleep, #slot_bound?, #subcomponent_for_name, synchronize_slot, #synchronize_slot?, #synchronize_slots, #template_filename, #tokenize_binding, #update_binding, #url_string

Constructor Details

This class inherits a constructor from SWS::Component

Instance Method Details

#append_to_response(response) ⇒ Object



17
18
19
# File 'lib/sws/Core/components/Image/Image.rb', line 17

def append_to_response ( response )
	response << generate_html()
end

#container?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/sws/Core/components/Image/Image.rb', line 12

def container? ()
	return false
end

#generate_htmlObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sws/Core/components/Image/Image.rb', line 22

def generate_html ()

	string = "<IMG"
	
	if ( slot_bound?( "resource" ) )
		framework = slot_bound?("framework") ? @slots["framework"].value : "app"
		src = app().adaptor.base_path() + app().resource_request_handler_key + "/" + framework + "/" + @slots["resource"].value
	elsif ( slot_bound?("src") ) 
		src = @slots["src"].value()
	end

	string << " src=\"#{src}\""

	["alt", "title"].each do |attr|
		if ( slot_bound?(attr) )
			string << " #{@slots[attr].to_tag_attribute}"
		end
	end

	string << generic_attr_string() << ">"

	return string

end