Class: ShopifyExtensions::Platform
- Inherits:
-
Struct
- Object
- Struct
- ShopifyExtensions::Platform
- Defined in:
- ext/shopify-extensions/shopify_extensions.rb
Instance Attribute Summary collapse
-
#ruby_config ⇒ Object
Returns the value of attribute ruby_config.
Instance Method Summary collapse
- #cpu ⇒ Object
- #format_path(path) ⇒ Object
-
#initialize(ruby_config = RbConfig::CONFIG) ⇒ Platform
constructor
A new instance of Platform.
- #os ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ruby_config = RbConfig::CONFIG) ⇒ Platform
Returns a new instance of Platform.
113 114 115 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 113 def initialize(ruby_config = RbConfig::CONFIG) super(ruby_config) end |
Instance Attribute Details
#ruby_config ⇒ Object
Returns the value of attribute ruby_config
112 113 114 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 112 def ruby_config @ruby_config end |
Instance Method Details
#cpu ⇒ Object
141 142 143 144 145 146 147 148 149 150 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 141 def cpu case ruby_config.fetch("host_cpu") when /arm.*64/ "arm64" when /64/ "amd64" else "386" end end |
#format_path(path) ⇒ Object
117 118 119 120 121 122 123 124 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 117 def format_path(path) case os when "windows" File.extname(path) != ".exe" ? path + ".exe" : path else path end end |
#os ⇒ Object
130 131 132 133 134 135 136 137 138 139 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 130 def os case ruby_config.fetch("host_os") when /linux/ "linux" when /darwin/ "darwin" else "windows" end end |
#to_s ⇒ Object
126 127 128 |
# File 'ext/shopify-extensions/shopify_extensions.rb', line 126 def to_s format("%{os}-%{cpu}", os: os, cpu: cpu) end |