Class: Gloo::Core::GlooSystem

Inherits:
Obj
  • Object
show all
Defined in:
lib/gloo/core/gloo_system.rb

Constant Summary collapse

KEYWORD =
'gloo'.freeze
KEYWORD_SHORT =
'$'.freeze

Instance Attribute Summary collapse

Attributes inherited from Obj

#children, #parent

Attributes inherited from Baseo

#name

Class Method Summary collapse

Instance Method Summary collapse

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_unload, #multiline_value?, #remove_child, #send_message, #set_parent

Constructor Details

#initialize(pn) ⇒ GlooSystem

Set up the object.



21
22
23
# File 'lib/gloo/core/gloo_system.rb', line 21

def initialize( pn )
  @pn = pn
end

Instance Attribute Details

#pnObject (readonly)

Returns the value of attribute pn.



18
19
20
# File 'lib/gloo/core/gloo_system.rb', line 18

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.

Returns:

  • (Boolean)


54
55
56
# File 'lib/gloo/core/gloo_system.rb', line 54

def self.can_create?
  false
end

.messagesObject

Get a list of message names that this object receives.



131
132
133
# File 'lib/gloo/core/gloo_system.rb', line 131

def self.messages
  return []
end

.open_for_platformObject

Get the command to open a file on this platform.



247
248
249
250
251
252
253
# File 'lib/gloo/core/gloo_system.rb', line 247

def self.open_for_platform
  platform = TTY::Platform.new
  return 'open' if platform.mac?
  return 'xdg-open' if platform.linux?

  return nil
end

.short_typenameObject

The short name of the object type.



35
36
37
# File 'lib/gloo/core/gloo_system.rb', line 35

def self.short_typename
  return KEYWORD_SHORT
end

.typenameObject

The name of the object type.



28
29
30
# File 'lib/gloo/core/gloo_system.rb', line 28

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.

Returns:

  • (Boolean)


120
121
122
# File 'lib/gloo/core/gloo_system.rb', line 120

def add_children_on_create?
  return false
end

#dispatch(msg) ⇒ Object

Dispatch the message and get the value.



136
137
138
139
140
141
142
# File 'lib/gloo/core/gloo_system.rb', line 136

def dispatch( msg )
  o = "msg_#{msg}"
  return self.public_send( o ) if self.respond_to? o

  $log.error "Message #{msg} not implemented"
  return false
end

#msg_gloo_configObject

Get the Gloo configuration directory



170
171
172
# File 'lib/gloo/core/gloo_system.rb', line 170

def msg_gloo_config
  return $settings.config_path
end

#msg_gloo_homeObject

Get the Gloo home directory



165
166
167
# File 'lib/gloo/core/gloo_system.rb', line 165

def msg_gloo_home
  return $settings.user_root
end

#msg_gloo_logObject

Get the Gloo log directory



180
181
182
# File 'lib/gloo/core/gloo_system.rb', line 180

def msg_gloo_log
  return $settings.log_path
end

#msg_gloo_projectsObject

Get the Gloo projects directory



175
176
177
# File 'lib/gloo/core/gloo_system.rb', line 175

def msg_gloo_projects
  return $settings.project_path
end

#msg_hostnameObject

Get the system hostname.



145
146
147
# File 'lib/gloo/core/gloo_system.rb', line 145

def msg_hostname
  return Socket.gethostname
end

#msg_platform_cpuObject

Get the platform CPU



203
204
205
206
# File 'lib/gloo/core/gloo_system.rb', line 203

def msg_platform_cpu
  platform = TTY::Platform.new
  return platform.cpu
end

#msg_platform_linux?Boolean

Is the platform Linux?

Returns:

  • (Boolean)


233
234
235
236
# File 'lib/gloo/core/gloo_system.rb', line 233

def msg_platform_linux?
  platform = TTY::Platform.new
  return platform.linux?
end

#msg_platform_mac?Boolean

Is the platform Mac?

Returns:

  • (Boolean)


239
240
241
242
# File 'lib/gloo/core/gloo_system.rb', line 239

def msg_platform_mac?
  platform = TTY::Platform.new
  return platform.mac?
end

#msg_platform_osObject

Get the platform Operating System



209
210
211
212
# File 'lib/gloo/core/gloo_system.rb', line 209

def msg_platform_os
  platform = TTY::Platform.new
  return platform.os
end

#msg_platform_unix?Boolean

Is the platform Unix?

Returns:

  • (Boolean)


227
228
229
230
# File 'lib/gloo/core/gloo_system.rb', line 227

def msg_platform_unix?
  platform = TTY::Platform.new
  return platform.unix?
end

#msg_platform_versionObject

Get the platform version



215
216
217
218
# File 'lib/gloo/core/gloo_system.rb', line 215

def msg_platform_version
  platform = TTY::Platform.new
  return platform.version
end

#msg_platform_windows?Boolean

Is the platform Windows?

Returns:

  • (Boolean)


221
222
223
224
# File 'lib/gloo/core/gloo_system.rb', line 221

def msg_platform_windows?
  platform = TTY::Platform.new
  return platform.windows?
end

#msg_screen_colsObject

Get the number of columns on screen.



194
195
196
# File 'lib/gloo/core/gloo_system.rb', line 194

def msg_screen_cols
  return Gloo::App::Settings.cols
end

#msg_screen_linesObject

Get the number of lines on screen.



189
190
191
# File 'lib/gloo/core/gloo_system.rb', line 189

def msg_screen_lines
  return Gloo::App::Settings.lines
end

#msg_userObject

Get the logged in User.



150
151
152
# File 'lib/gloo/core/gloo_system.rb', line 150

def msg_user
  return ENV[ 'USER' ]
end

#msg_user_homeObject

Get the user’s home directory.



155
156
157
# File 'lib/gloo/core/gloo_system.rb', line 155

def msg_user_home
  return File.expand_path( '~' )
end

#msg_working_dirObject

Get the working directory.



160
161
162
# File 'lib/gloo/core/gloo_system.rb', line 160

def msg_working_dir
  return Dir.pwd
end

#paramObject

Get the parameter.



65
66
67
68
69
# File 'lib/gloo/core/gloo_system.rb', line 65

def param
  return nil unless @pn && @pn.segments.count > 1

  return @pn.segments[ 1..-1 ].join( '_' )
end

#root?Boolean

Is this the root object?

Returns:

  • (Boolean)


47
48
49
# File 'lib/gloo/core/gloo_system.rb', line 47

def root?
  return false
end

#set_value(new_value) ⇒ Object

There is no value object in the system.



81
82
83
# File 'lib/gloo/core/gloo_system.rb', line 81

def set_value( new_value )
  # overriding base functionality with dummy function
end

#type_displayObject

The object type, suitable for display.



42
43
44
# File 'lib/gloo/core/gloo_system.rb', line 42

def type_display
  return self.class.typename
end

#valueObject

Get the system value.



74
75
76
# File 'lib/gloo/core/gloo_system.rb', line 74

def value
  return dispatch param
end

#value_displayObject

Get the value for display purposes.



88
89
90
# File 'lib/gloo/core/gloo_system.rb', line 88

def value_display
  return value
end

#value_is_array?Boolean

Is the value an Array?

Returns:

  • (Boolean)


102
103
104
# File 'lib/gloo/core/gloo_system.rb', line 102

def value_is_array?
  return false
end

#value_is_blank?Boolean

Is the value a blank string?

Returns:

  • (Boolean)


109
110
111
# File 'lib/gloo/core/gloo_system.rb', line 109

def value_is_blank?
  return true
end

#value_string?Boolean

Is the value a String?

Returns:

  • (Boolean)


95
96
97
# File 'lib/gloo/core/gloo_system.rb', line 95

def value_string?
  return true
end