Class: Bitferry::Endpoint::Bitferry
- Inherits:
-
Bitferry::Endpoint
- Object
- Bitferry::Endpoint
- Bitferry::Endpoint::Bitferry
- Defined in:
- lib/bitferry.rb
Constant Summary
Constants inherited from Bitferry::Endpoint
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#volume_tag ⇒ Object
readonly
Returns the value of attribute volume_tag.
Instance Method Summary collapse
- #externalize ⇒ Object
- #generation ⇒ Object
-
#initialize(volume, path) ⇒ Bitferry
constructor
A new instance of Bitferry.
- #intact? ⇒ Boolean
- #refers?(volume) ⇒ Boolean
- #restore(hash) ⇒ Object
- #root ⇒ Object
- #show_status ⇒ Object
Methods inherited from Bitferry::Endpoint
Constructor Details
#initialize(volume, path) ⇒ Bitferry
Returns a new instance of Bitferry.
1320 1321 1322 1323 1324 |
# File 'lib/bitferry.rb', line 1320 def initialize(volume, path) @volume_tag = volume.tag @path = Pathname.new(path) raise ArgumentError, "expected relative path but got #{self.path}" unless (/^[\.\/]/ =~ self.path.to_s).nil? end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
1314 1315 1316 |
# File 'lib/bitferry.rb', line 1314 def path @path end |
#volume_tag ⇒ Object (readonly)
Returns the value of attribute volume_tag.
1311 1312 1313 |
# File 'lib/bitferry.rb', line 1311 def volume_tag @volume_tag end |
Instance Method Details
#externalize ⇒ Object
1333 1334 1335 1336 1337 1338 1339 |
# File 'lib/bitferry.rb', line 1333 def externalize { endpoint: :bitferry, volume: volume_tag, path: path } end |
#generation ⇒ Object
1351 1352 1353 1354 |
# File 'lib/bitferry.rb', line 1351 def generation v = Volume[volume_tag] v ? v.generation : 0 end |
#refers?(volume) ⇒ Boolean
1348 |
# File 'lib/bitferry.rb', line 1348 def refers?(volume) = volume.tag == volume_tag |
#restore(hash) ⇒ Object
1327 1328 1329 1330 |
# File 'lib/bitferry.rb', line 1327 def restore(hash) @volume_tag = hash.fetch(:volume) @path = Pathname.new(hash.fetch(:path)) end |
#root ⇒ Object
1317 |
# File 'lib/bitferry.rb', line 1317 def root = Volume[volume_tag].root.join(path) |
#show_status ⇒ Object
1342 |
# File 'lib/bitferry.rb', line 1342 def show_status = intact? ? ":#{volume_tag}:#{path}" : ":{#{volume_tag}}:#{path}" |