Class: Zipping::Entity
- Inherits:
-
Object
- Object
- Zipping::Entity
- Defined in:
- lib/zipping.rb
Class Method Summary collapse
- .entities_from(files) ⇒ Object
- .entities_from_array(arr) ⇒ Object
-
.entity_from(ent) ⇒ Object
Create an entity Hash with a path String.
- .entity_from_path(path) ⇒ Object
- .linked_path(abs_path, link) ⇒ Object
Class Method Details
.entities_from(files) ⇒ Object
384 385 386 387 388 389 390 |
# File 'lib/zipping.rb', line 384 def self.entities_from(files) if files.is_a? Array entities_from_array files else [entity_from(files)] end end |
.entities_from_array(arr) ⇒ Object
401 402 403 |
# File 'lib/zipping.rb', line 401 def self.entities_from_array(arr) arr.map{|ent| entity_from ent}.delete_if(&:nil?) end |
.entity_from(ent) ⇒ Object
Create an entity Hash with a path String
393 394 395 396 397 398 399 |
# File 'lib/zipping.rb', line 393 def self.entity_from(ent) if ent.is_a?(Hash) && File.exists?(ent[:path]) ent elsif ent.is_a?(String) && File.exists?(ent) entity_from_path ent end end |
.entity_from_path(path) ⇒ Object
405 406 407 408 409 410 411 |
# File 'lib/zipping.rb', line 405 def self.entity_from_path(path) { :path => path, :name => File.basename(path), :time => File.mtime(path) } end |
.linked_path(abs_path, link) ⇒ Object
413 414 415 |
# File 'lib/zipping.rb', line 413 def self.linked_path(abs_path, link) (Pathname.new(abs_path).parent + link).('/').to_s[1..-1] end |