Class: Warp::Dir::Point
Instance Attribute Summary collapse
-
#full_path ⇒ Object
Returns the value of attribute full_path.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #absolute_path ⇒ Object
- #eql?(another) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, full_path) ⇒ Point
constructor
A new instance of Point.
- #inspect ⇒ Object
- #path ⇒ Object
- #relative_path ⇒ Object
- #to_s(width = 0) ⇒ Object
Constructor Details
#initialize(name, full_path) ⇒ Point
Returns a new instance of Point.
8 9 10 11 12 13 |
# File 'lib/warp/dir/point.rb', line 8 def initialize(name, full_path) raise ArgumentError.new ':name is required' if name.nil? raise ArgumentError.new ':full_path is required' if full_path.nil? @full_path = Warp::Dir.absolute full_path @name = name.to_sym end |
Instance Attribute Details
#full_path ⇒ Object
Returns the value of attribute full_path.
6 7 8 |
# File 'lib/warp/dir/point.rb', line 6 def full_path @full_path end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/warp/dir/point.rb', line 6 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
39 40 41 |
# File 'lib/warp/dir/point.rb', line 39 def <=>(other) name <=> other.name end |
#absolute_path ⇒ Object
15 16 17 |
# File 'lib/warp/dir/point.rb', line 15 def absolute_path full_path end |
#eql?(another) ⇒ Boolean
43 44 45 46 47 48 49 |
# File 'lib/warp/dir/point.rb', line 43 def eql?(another) return false unless another.is_a?(Warp::Dir::Point) %i(name full_path).each do |attribute| return false unless send(attribute) == another.send(attribute) end true end |
#hash ⇒ Object
35 36 37 |
# File 'lib/warp/dir/point.rb', line 35 def hash Digest::SHA1.base64digest("#{full_path.hash}#{name.hash}").hash end |
#inspect ⇒ Object
27 28 29 |
# File 'lib/warp/dir/point.rb', line 27 def inspect sprintf("(#{object_id})[name: '%s', path: '%s']", name, relative_path) end |
#path ⇒ Object
23 24 25 |
# File 'lib/warp/dir/point.rb', line 23 def path absolute_path end |
#relative_path ⇒ Object
19 20 21 |
# File 'lib/warp/dir/point.rb', line 19 def relative_path Warp::Dir.relative full_path end |
#to_s(width = 0) ⇒ Object
31 32 33 |
# File 'lib/warp/dir/point.rb', line 31 def to_s(width = 0) sprintf("%#{width}s -> %s", name, relative_path) end |