Class: CLI::UI::OS

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/cli/ui/os.rb

Constant Summary collapse

MAC =
OS.new
LINUX =
OS.new
WINDOWS =
OS.new(emoji: false, color_prompt: false, arrow_keys: false, shift_cursor: true)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from T::Sig

sig

Constructor Details

#initialize(emoji: true, color_prompt: true, arrow_keys: true, shift_cursor: false) ⇒ OS

Returns a new instance of OS.



11
12
13
14
15
16
# File 'lib/cli/ui/os.rb', line 11

def initialize(emoji: true, color_prompt: true, arrow_keys: true, shift_cursor: false)
  @emoji = emoji
  @color_prompt = color_prompt
  @arrow_keys = arrow_keys
  @shift_cursor = shift_cursor
end

Class Method Details

.currentObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cli/ui/os.rb', line 42

def current
  @current_os ||= case RbConfig::CONFIG['host_os']
  when /darwin/
    MAC
  when /linux/
    LINUX
  else
    if RUBY_PLATFORM !~ /cygwin/ && ENV['OS'] == 'Windows_NT'
      WINDOWS
    else
      raise "Could not determine OS from host_os #{RbConfig::CONFIG["host_os"]}"
    end
  end
end

Instance Method Details

#shift_cursor_back_on_horizontal_absolute?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/cli/ui/os.rb', line 34

def shift_cursor_back_on_horizontal_absolute?
  @shift_cursor
end

#suggest_arrow_keys?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cli/ui/os.rb', line 29

def suggest_arrow_keys?
  @arrow_keys
end

#use_color_prompt?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/cli/ui/os.rb', line 24

def use_color_prompt?
  @color_prompt
end

#use_emoji?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cli/ui/os.rb', line 19

def use_emoji?
  @emoji
end