Class: Josean::Application
- Inherits:
-
Object
- Object
- Josean::Application
- Defined in:
- lib/josean.rb
Instance Method Summary collapse
-
#body_header(image, style_image, style) ⇒ Object
Sets the body header of the application image URL to the image style_image Hash containing the CSS style of the image style Hash containing the CSS style of the frame.
-
#body_style(style) ⇒ Object
Add a body style section style Hash containing the CSS style of the frame.
-
#get_request_action(name_of_resource, url, view) ⇒ Object
Add a get call with a given action name name_of_resource Name of the resource that this request will be attached to url URL to which the request will be issued view View to which the application will be transitioned on success.
-
#head(title, description, icon, style) ⇒ Object
Sets the head of the application title Title of the application description Description of the application icon URL to the icon image style Hash containing the CSS style.
-
#initialize(application_url) ⇒ Application
constructor
A new instance of Application.
-
#post_request_action(name_of_resource, url, data_hash, view) ⇒ Object
Add a post call with a given action name name_of_resource Name of the resource that this request will be attached to url URL to which the request will be issued view View to which the application will be transitioned on success.
-
#put_request_action(name_of_resource, url, data_hash, view) ⇒ Object
Add a put call with a given action name name_of_resource Name of the resource that this request will be attached to url URL to which the request will be issued view View to which the application will be transitioned on success.
-
#scrolled_section(type, style) ⇒ Object
Add a body section that can scroll components and return a handler for it.
-
#scrolled_section_component(section, component) ⇒ Object
Add a component to a given scrolled section section handler to which section component Component to be added.
-
#section ⇒ Object
Add a body section and return a handler for it.
-
#section_item(section, item) ⇒ Object
Add an item to a given section section handler to which section item Item to be added.
-
#to_json ⇒ Object
Returns the json so that it can be served.
Constructor Details
#initialize(application_url) ⇒ Application
Returns a new instance of Application.
7 8 9 10 11 12 13 |
# File 'lib/josean.rb', line 7 def initialize application_url @application_url = application_url @total_configuration = {} @total_configuration[:head] = {} @total_configuration[:body] = {} @total_configuration[:body][:sections] = [] end |
Instance Method Details
#body_header(image, style_image, style) ⇒ Object
Sets the body header of the application image URL to the image style_image Hash containing the CSS style of the image style Hash containing the CSS style of the frame
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/josean.rb', line 33 def body_header image, style_image, style @total_configuration[:body][:header] = { title: { type: 'image', url: image, style: style_image }, style: style } end |
#body_style(style) ⇒ Object
Add a body style section style Hash containing the CSS style of the frame
47 48 49 |
# File 'lib/josean.rb', line 47 def body_style style @total_configuration[:body][:style] = style end |
#get_request_action(name_of_resource, url, view) ⇒ Object
Add a get call with a given action name name_of_resource Name of the resource that this request will be attached to url URL to which the request will be issued view View to which the application will be transitioned on success
90 91 92 |
# File 'lib/josean.rb', line 90 def get_request_action name_of_resource, url, view create_network_request 'get', name_of_resource, url, nil, view end |
#head(title, description, icon, style) ⇒ Object
Sets the head of the application title Title of the application description Description of the application icon URL to the icon image style Hash containing the CSS style
21 22 23 24 25 26 |
# File 'lib/josean.rb', line 21 def head title, description, icon, style @total_configuration[:head] = {title: title, description: description, icon: icon, style: style} end |
#post_request_action(name_of_resource, url, data_hash, view) ⇒ Object
Add a post call with a given action name name_of_resource Name of the resource that this request will be attached to url URL to which the request will be issued view View to which the application will be transitioned on success
99 100 101 |
# File 'lib/josean.rb', line 99 def post_request_action name_of_resource, url, data_hash, view create_network_request 'post', name_of_resource, url, data_hash, view end |
#put_request_action(name_of_resource, url, data_hash, view) ⇒ Object
Add a put call with a given action name name_of_resource Name of the resource that this request will be attached to url URL to which the request will be issued view View to which the application will be transitioned on success
108 109 110 |
# File 'lib/josean.rb', line 108 def put_request_action name_of_resource, url, data_hash, view create_network_request 'put', name_of_resource, url, data_hash, view end |
#scrolled_section(type, style) ⇒ Object
Add a body section that can scroll components and return a handler for it
59 60 61 62 63 64 65 66 67 |
# File 'lib/josean.rb', line 59 def scrolled_section type, style if valid_type?(type) and style.is_a? Hash @total_configuration[:body][:sections] << {items: []} @total_configuration[:body][:sections].last[:items] << {type: type, style: style, components: []} @total_configuration[:body][:sections].last[:items] else nil end end |
#scrolled_section_component(section, component) ⇒ Object
Add a component to a given scrolled section section handler to which section component Component to be added. It needs to be a Jasonette object
81 82 83 |
# File 'lib/josean.rb', line 81 def scrolled_section_component section, component section.last[:components] << component if section.is_a? Array and section.last.keys.include? :components end |
#section ⇒ Object
Add a body section and return a handler for it
52 53 54 55 |
# File 'lib/josean.rb', line 52 def section @total_configuration[:body][:sections] << {items: []} @total_configuration[:body][:sections].last[:items] end |
#section_item(section, item) ⇒ Object
Add an item to a given section section handler to which section item Item to be added. It needs to be a Jasonette object
73 74 75 |
# File 'lib/josean.rb', line 73 def section_item section, item section << item if section.is_a? Array end |
#to_json ⇒ Object
Returns the json so that it can be served
114 115 116 117 118 |
# File 'lib/josean.rb', line 114 def to_json if valid? '{"$jason":' + JSON.unparse(@total_configuration) + '}' end end |