Class: Gloo::Core::GlooSystem
- Defined in:
- lib/gloo/core/gloo_system.rb
Constant Summary collapse
- KEYWORD =
'gloo'.freeze
- KEYWORD_SHORT =
'$'.freeze
Constants inherited from Baseo
Instance Attribute Summary collapse
-
#pn ⇒ Object
readonly
Returns the value of attribute pn.
Attributes inherited from Obj
Attributes inherited from Baseo
Class Method Summary collapse
-
.can_create? ⇒ Boolean
Can this object be created? This is true by default and only false for some special cases such as the System object.
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.open_for_platform ⇒ Object
Get the command to open a file on this platform.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
-
#dispatch(msg) ⇒ Object
Dispatch the message and get the value.
-
#initialize(engine, pn) ⇒ GlooSystem
constructor
Set up the object.
-
#msg_gloo_config ⇒ Object
Get the Gloo configuration directory.
-
#msg_gloo_home ⇒ Object
Get the Gloo home directory.
-
#msg_gloo_log ⇒ Object
Get the Gloo log directory.
-
#msg_gloo_projects ⇒ Object
Get the Gloo projects directory.
-
#msg_hostname ⇒ Object
Get the system hostname.
-
#msg_line ⇒ Object
Carriage return (line feed).
-
#msg_platform_cpu ⇒ Object
Get the platform CPU.
-
#msg_platform_linux? ⇒ Boolean
Is the platform Linux?.
-
#msg_platform_mac? ⇒ Boolean
Is the platform Mac?.
-
#msg_platform_os ⇒ Object
Get the platform Operating System.
-
#msg_platform_unix? ⇒ Boolean
Is the platform Unix?.
-
#msg_platform_version ⇒ Object
Get the platform version.
-
#msg_platform_windows? ⇒ Boolean
Is the platform Windows?.
-
#msg_screen_cols ⇒ Object
Get the number of columns on screen.
-
#msg_screen_lines ⇒ Object
Get the number of lines on screen.
-
#msg_user ⇒ Object
Get the logged in User.
-
#msg_user_home ⇒ Object
Get the user’s home directory.
-
#msg_working_dir ⇒ Object
Get the working directory.
-
#param ⇒ Object
Get the parameter.
-
#root? ⇒ Boolean
Is this the root object?.
-
#set_value(new_value) ⇒ Object
There is no value object in the system.
-
#type_display ⇒ Object
The object type, suitable for display.
-
#value ⇒ Object
Get the system value.
-
#value_display ⇒ Object
Get the value for display purposes.
-
#value_is_array? ⇒ Boolean
Is the value an Array?.
-
#value_is_blank? ⇒ Boolean
Is the value a blank string?.
-
#value_string? ⇒ Boolean
Is the value a String?.
Methods inherited from Obj
#add_child, #add_default_children, #can_receive_message?, #child_count, #contains_child?, #delete_children, #display_value, #find_add_child, #find_child, help, inherited, #msg_reload, #msg_unload, #multiline_value?, #remove_child, #send_message, #set_parent
Constructor Details
#initialize(engine, pn) ⇒ GlooSystem
Set up the object.
22 23 24 25 |
# File 'lib/gloo/core/gloo_system.rb', line 22 def initialize( engine, pn ) @engine = engine @pn = pn end |
Instance Attribute Details
#pn ⇒ Object (readonly)
Returns the value of attribute pn.
19 20 21 |
# File 'lib/gloo/core/gloo_system.rb', line 19 def pn @pn end |
Class Method Details
.can_create? ⇒ Boolean
Can this object be created? This is true by default and only false for some special cases such as the System object.
56 57 58 |
# File 'lib/gloo/core/gloo_system.rb', line 56 def self.can_create? false end |
.messages ⇒ Object
Get a list of message names that this object receives.
133 134 135 |
# File 'lib/gloo/core/gloo_system.rb', line 133 def self. return [] end |
.open_for_platform ⇒ Object
Get the command to open a file on this platform.
256 257 258 259 260 261 262 263 |
# File 'lib/gloo/core/gloo_system.rb', line 256 def self.open_for_platform platform = TTY::Platform.new return 'open' if platform.mac? return 'xdg-open' if platform.linux? return 'Start-Process' if platform.windows? return nil end |
.short_typename ⇒ Object
The short name of the object type.
37 38 39 |
# File 'lib/gloo/core/gloo_system.rb', line 37 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
30 31 32 |
# File 'lib/gloo/core/gloo_system.rb', line 30 def self.typename return KEYWORD end |
Instance Method Details
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
122 123 124 |
# File 'lib/gloo/core/gloo_system.rb', line 122 def add_children_on_create? return false end |
#dispatch(msg) ⇒ Object
Dispatch the message and get the value.
138 139 140 141 142 143 144 |
# File 'lib/gloo/core/gloo_system.rb', line 138 def dispatch( msg ) o = "msg_#{msg}" return self.public_send( o ) if self.respond_to? o @engine.log.error "Message #{msg} not implemented" return false end |
#msg_gloo_config ⇒ Object
Get the Gloo configuration directory
172 173 174 |
# File 'lib/gloo/core/gloo_system.rb', line 172 def msg_gloo_config return @engine.settings.config_path end |
#msg_gloo_home ⇒ Object
Get the Gloo home directory
167 168 169 |
# File 'lib/gloo/core/gloo_system.rb', line 167 def msg_gloo_home return @engine.settings.user_root end |
#msg_gloo_log ⇒ Object
Get the Gloo log directory
182 183 184 |
# File 'lib/gloo/core/gloo_system.rb', line 182 def msg_gloo_log return @engine.settings.log_path end |
#msg_gloo_projects ⇒ Object
Get the Gloo projects directory
177 178 179 |
# File 'lib/gloo/core/gloo_system.rb', line 177 def msg_gloo_projects return @engine.settings.project_path end |
#msg_hostname ⇒ Object
Get the system hostname.
147 148 149 |
# File 'lib/gloo/core/gloo_system.rb', line 147 def msg_hostname return Socket.gethostname end |
#msg_line ⇒ Object
Carriage return (line feed)
191 192 193 |
# File 'lib/gloo/core/gloo_system.rb', line 191 def msg_line return "\n" end |
#msg_platform_cpu ⇒ Object
Get the platform CPU
214 215 216 217 |
# File 'lib/gloo/core/gloo_system.rb', line 214 def msg_platform_cpu platform = TTY::Platform.new return platform.cpu end |
#msg_platform_linux? ⇒ Boolean
Is the platform Linux?
243 244 245 246 |
# File 'lib/gloo/core/gloo_system.rb', line 243 def msg_platform_linux? platform = TTY::Platform.new return platform.linux? end |
#msg_platform_mac? ⇒ Boolean
Is the platform Mac?
249 250 251 |
# File 'lib/gloo/core/gloo_system.rb', line 249 def msg_platform_mac? return OS.mac? end |
#msg_platform_os ⇒ Object
Get the platform Operating System
220 221 222 223 |
# File 'lib/gloo/core/gloo_system.rb', line 220 def msg_platform_os platform = TTY::Platform.new return platform.os end |
#msg_platform_unix? ⇒ Boolean
Is the platform Unix?
237 238 239 240 |
# File 'lib/gloo/core/gloo_system.rb', line 237 def msg_platform_unix? platform = TTY::Platform.new return platform.unix? end |
#msg_platform_version ⇒ Object
Get the platform version
226 227 228 229 |
# File 'lib/gloo/core/gloo_system.rb', line 226 def msg_platform_version platform = TTY::Platform.new return platform.version end |
#msg_platform_windows? ⇒ Boolean
Is the platform Windows?
232 233 234 |
# File 'lib/gloo/core/gloo_system.rb', line 232 def msg_platform_windows? return OS.windows? end |
#msg_screen_cols ⇒ Object
Get the number of columns on screen.
205 206 207 |
# File 'lib/gloo/core/gloo_system.rb', line 205 def msg_screen_cols return Gloo::App::Settings.cols( @engine ) end |
#msg_screen_lines ⇒ Object
Get the number of lines on screen.
200 201 202 |
# File 'lib/gloo/core/gloo_system.rb', line 200 def msg_screen_lines return Gloo::App::Settings.lines( @engine ) end |
#msg_user ⇒ Object
Get the logged in User.
152 153 154 |
# File 'lib/gloo/core/gloo_system.rb', line 152 def msg_user return ENV[ 'USER' ] end |
#msg_user_home ⇒ Object
Get the user’s home directory.
157 158 159 |
# File 'lib/gloo/core/gloo_system.rb', line 157 def msg_user_home return File.( '~' ) end |
#msg_working_dir ⇒ Object
Get the working directory.
162 163 164 |
# File 'lib/gloo/core/gloo_system.rb', line 162 def msg_working_dir return Dir.pwd end |
#param ⇒ Object
Get the parameter.
67 68 69 70 71 |
# File 'lib/gloo/core/gloo_system.rb', line 67 def param return nil unless @pn && @pn.segments.count > 1 return @pn.segments[ 1..-1 ].join( '_' ) end |
#root? ⇒ Boolean
Is this the root object?
49 50 51 |
# File 'lib/gloo/core/gloo_system.rb', line 49 def root? return false end |
#set_value(new_value) ⇒ Object
There is no value object in the system.
83 84 85 |
# File 'lib/gloo/core/gloo_system.rb', line 83 def set_value( new_value ) # overriding base functionality with dummy function end |
#type_display ⇒ Object
The object type, suitable for display.
44 45 46 |
# File 'lib/gloo/core/gloo_system.rb', line 44 def type_display return self.class.typename end |
#value ⇒ Object
Get the system value.
76 77 78 |
# File 'lib/gloo/core/gloo_system.rb', line 76 def value return dispatch param end |
#value_display ⇒ Object
Get the value for display purposes.
90 91 92 |
# File 'lib/gloo/core/gloo_system.rb', line 90 def value_display return value end |
#value_is_array? ⇒ Boolean
Is the value an Array?
104 105 106 |
# File 'lib/gloo/core/gloo_system.rb', line 104 def value_is_array? return false end |
#value_is_blank? ⇒ Boolean
Is the value a blank string?
111 112 113 |
# File 'lib/gloo/core/gloo_system.rb', line 111 def value_is_blank? return true end |
#value_string? ⇒ Boolean
Is the value a String?
97 98 99 |
# File 'lib/gloo/core/gloo_system.rb', line 97 def value_string? return true end |