Module: SmalrubyEditor
- Defined in:
- lib/smalruby_editor.rb,
lib/smalruby_editor/version.rb,
lib/smalruby_editor/blockly_message_helper.rb
Defined Under Namespace
Modules: BlocklyMessageHelper
Constant Summary collapse
- COLORS =
ジャンルのカラー
{ character: 198, control: 43, data: 330, etc: 340, events: 33, looks: 270, motion: 208, operators: 100, pen: 160, ruby: 340, sensing: 190, sound: 300, }
- VERSION =
'0.4.2'
Class Method Summary collapse
- .create_home_directory(home_dir = nil) ⇒ Object
-
.home_directory ⇒ Object
return smalruby’s home directory (default is ‘~/.smalruby-editor’).
- .hsv_to_rgb(h, s, v) ⇒ Object
-
.osx? ⇒ Boolean
Mac OS Xかどうかを返す.
-
.raspberrypi? ⇒ Boolean
Raspberry Piかどうかを返す.
-
.windows? ⇒ Boolean
Windowsかどうかを返す.
Class Method Details
.create_home_directory(home_dir = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/smalruby_editor.rb', line 52 def create_home_directory(home_dir = nil) if home_dir.blank? path = ENV['SMALRUBY_EDITOR_HOME'] || '~/.smalruby-editor' home_dir = Pathname(path). end create_under_home_directories(home_dir) create_database_yml(home_dir) create_config_yml(home_dir) home_dir end |
.home_directory ⇒ Object
return smalruby’s home directory (default is ‘~/.smalruby-editor’).
46 47 48 49 |
# File 'lib/smalruby_editor.rb', line 46 def home_directory path = ENV['SMALRUBY_EDITOR_HOME'] || '~/.smalruby-editor' Pathname(path). end |
.hsv_to_rgb(h, s, v) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/smalruby_editor.rb', line 22 def hsv_to_rgb(h, s, v) s /= 100.0 v /= 100.0 c = v * s x = c * (1 - ((h / 60.0) % 2 - 1).abs) m = v - c r, g, b = *( case when h < 60 then [c, x, 0] when h < 120 then [x, c, 0] when h < 180 then [0, c, x] when h < 240 then [0, x, c] when h < 300 then [x, 0, c] else [c, 0, x] end ) [r, g, b].map { |channel| sprintf('%02x', ((channel + m) * 255).ceil) }.join end |
.osx? ⇒ Boolean
Mac OS Xかどうかを返す
77 78 79 80 81 82 83 84 85 |
# File 'lib/smalruby_editor.rb', line 77 def osx? if Rails.env != 'test' && (ENV['SMALRUBY_EDITOR_OSX_MODE'] || File.exist?(Rails.root.join('tmp', 'osx'))) true else /darwin/ =~ RbConfig::CONFIG['arch'] end end |
.raspberrypi? ⇒ Boolean
Raspberry Piかどうかを返す
65 66 67 68 69 70 71 72 73 |
# File 'lib/smalruby_editor.rb', line 65 def raspberrypi? if Rails.env != 'test' && (ENV['SMALRUBY_EDITOR_RASPBERRYPI_MODE'] || File.exist?(Rails.root.join('tmp', 'raspberrypi'))) true else RbConfig::CONFIG['arch'] == 'armv6l-linux-eabihf' end end |
.windows? ⇒ Boolean
Windowsかどうかを返す
89 90 91 92 93 94 95 96 97 |
# File 'lib/smalruby_editor.rb', line 89 def windows? if Rails.env != 'test' && (ENV['SMALRUBY_EDITOR_WINDOWS_MODE'] || File.exist?(Rails.root.join('tmp', 'windows'))) true else /windows|mingw|cygwin/i.match(RbConfig::CONFIG['arch']) end end |