Class: Rpremote::Target
- Inherits:
-
Object
- Object
- Rpremote::Target
- Defined in:
- lib/rpremote/target.rb,
sig/rpremote.rbs
Constant Summary collapse
- DEFAULT_LANGUAGE =
"picoruby"- DEFAULT_LANGUAGE_VERSION =
"4.0.3"- DEFAULT_BOARD =
"pico2"- DEFAULT_CACHE_DIR =
"firmware"- IDENTIFIER_PATTERN =
/\A[a-zA-Z0-9][a-zA-Z0-9._-]*\z/
Instance Attribute Summary collapse
-
#board ⇒ String
readonly
Returns the value of attribute board.
-
#cache_dir ⇒ String
readonly
Returns the value of attribute cache_dir.
-
#language ⇒ String
readonly
Returns the value of attribute language.
-
#language_version ⇒ String
readonly
Returns the value of attribute language_version.
Instance Method Summary collapse
- #firmware_path(root: nil) ⇒ String
-
#initialize(language: DEFAULT_LANGUAGE, language_version: DEFAULT_LANGUAGE_VERSION, board: DEFAULT_BOARD, cache_dir: DEFAULT_CACHE_DIR, firmware: nil) ⇒ Target
constructor
A new instance of Target.
- #source_dir(root: Dir.pwd) ⇒ String
Constructor Details
#initialize(language: DEFAULT_LANGUAGE, language_version: DEFAULT_LANGUAGE_VERSION, board: DEFAULT_BOARD, cache_dir: DEFAULT_CACHE_DIR, firmware: nil) ⇒ Target
Returns a new instance of Target.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rpremote/target.rb', line 13 def initialize( language: DEFAULT_LANGUAGE, language_version: DEFAULT_LANGUAGE_VERSION, board: DEFAULT_BOARD, cache_dir: DEFAULT_CACHE_DIR, firmware: nil ) @language = validate_identifier(:language, language) @language_version = validate_identifier(:language_version, language_version) @board = validate_identifier(:board, board) @cache_dir = String(cache_dir).gsub("{version}", @language_version) @firmware = firmware raise ArgumentError, "cache must not be empty" if @cache_dir.empty? end |
Instance Attribute Details
#board ⇒ String (readonly)
Returns the value of attribute board.
11 12 13 |
# File 'lib/rpremote/target.rb', line 11 def board @board end |
#cache_dir ⇒ String (readonly)
Returns the value of attribute cache_dir.
11 12 13 |
# File 'lib/rpremote/target.rb', line 11 def cache_dir @cache_dir end |
#language ⇒ String (readonly)
Returns the value of attribute language.
11 12 13 |
# File 'lib/rpremote/target.rb', line 11 def language @language end |
#language_version ⇒ String (readonly)
Returns the value of attribute language_version.
11 12 13 |
# File 'lib/rpremote/target.rb', line 11 def language_version @language_version end |
Instance Method Details
#firmware_path(root: nil) ⇒ String
32 33 34 35 |
# File 'lib/rpremote/target.rb', line 32 def firmware_path(root: nil) path = @firmware || File.join(cache_dir, "#{language}-#{language_version}-#{board}.uf2") root ? File.(path, root) : path end |
#source_dir(root: Dir.pwd) ⇒ String
28 29 30 |
# File 'lib/rpremote/target.rb', line 28 def source_dir(root: Dir.pwd) File.(File.join(cache_dir, "#{language}-#{language_version}"), root) end |