Class: Gloo::Objs::Uri

Inherits:
Core::Obj show all
Defined in:
lib/gloo/objs/web/uri.rb

Constant Summary collapse

KEYWORD =
'uri'.freeze
KEYWORD_SHORT =
'url'.freeze

Instance Attribute Summary

Attributes inherited from Core::Obj

#children, #parent, #value

Attributes inherited from Core::Baseo

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Obj

#add_child, #add_children_on_create?, #add_default_children, can_create?, #can_receive_message?, #child_count, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, help, inherited, #initialize, #msg_unload, #pn, #remove_child, #root?, #send_message, #set_parent, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?

Methods inherited from Core::Baseo

#initialize, #type_display

Constructor Details

This class inherits a constructor from Gloo::Core::Obj

Class Method Details

.messagesObject

Get a list of message names that this object receives.



51
52
53
54
55
56
# File 'lib/gloo/objs/web/uri.rb', line 51

def self.messages
  basic = %w[open]
  gets = %w[get_scheme get_host get_path]
  more = %w[get_query get_fragment]
  return super + basic + gets + more
end

.short_typenameObject

The short name of the object type.



25
26
27
# File 'lib/gloo/objs/web/uri.rb', line 25

def self.short_typename
  return KEYWORD_SHORT
end

.typenameObject

The name of the object type.



18
19
20
# File 'lib/gloo/objs/web/uri.rb', line 18

def self.typename
  return KEYWORD
end

Instance Method Details

#msg_get_fragmentObject

Get the URI fragment that comes after the ‘#’ in the URL. Might be used to scroll down in the page.



62
63
64
65
66
67
68
# File 'lib/gloo/objs/web/uri.rb', line 62

def msg_get_fragment
  return unless value

  o = URI( value ).fragment
  $engine.heap.it.set_to o
  return o
end

#msg_get_hostObject

Get the URI host. Example: google.com



98
99
100
101
102
103
104
# File 'lib/gloo/objs/web/uri.rb', line 98

def msg_get_host
  return unless value

  o = URI( value ).host
  $engine.heap.it.set_to o
  return o
end

#msg_get_pathObject

Get the URI path. Example: /posts



86
87
88
89
90
91
92
# File 'lib/gloo/objs/web/uri.rb', line 86

def msg_get_path
  return unless value

  o = URI( value ).path
  $engine.heap.it.set_to o
  return o
end

#msg_get_queryObject

Get the URI query parameters. Example: id=121



74
75
76
77
78
79
80
# File 'lib/gloo/objs/web/uri.rb', line 74

def msg_get_query
  return unless value

  o = URI( value ).query
  $engine.heap.it.set_to o
  return o
end

#msg_get_schemeObject

Get the URI Scheme. Example: http



110
111
112
113
114
115
116
# File 'lib/gloo/objs/web/uri.rb', line 110

def msg_get_scheme
  return unless value

  o = URI( value ).scheme
  $engine.heap.it.set_to o
  return o
end

#msg_openObject

Open the URI in the default browser.



121
122
123
124
125
126
127
# File 'lib/gloo/objs/web/uri.rb', line 121

def msg_open
  return unless value

  cmd = Gloo::Core::GlooSystem.open_for_platform
  cmd_with_param = "#{cmd} \"#{value}\""
  `#{cmd_with_param}`
end

#multiline_value?Boolean

Does this object support multi-line values? Initially only true for scripts.

Returns:



40
41
42
# File 'lib/gloo/objs/web/uri.rb', line 40

def multiline_value?
  return false
end

#set_value(new_value) ⇒ Object

Set the value with any necessary type conversions.



32
33
34
# File 'lib/gloo/objs/web/uri.rb', line 32

def set_value( new_value )
  self.value = new_value.to_s
end