Class: CC::Config::Prepare::Fetch::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/config/prepare.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, path = nil) ⇒ Entry

Returns a new instance of Entry.



59
60
61
62
63
64
# File 'lib/cc/config/prepare.rb', line 59

def initialize(url, path = nil)
  @url = url
  @path = path || url.split("/").last

  validate_path!
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



50
51
52
# File 'lib/cc/config/prepare.rb', line 50

def path
  @path
end

#urlObject (readonly)

Returns the value of attribute url.



50
51
52
# File 'lib/cc/config/prepare.rb', line 50

def url
  @url
end

Class Method Details

.from_data(data) ⇒ Object



52
53
54
55
56
57
# File 'lib/cc/config/prepare.rb', line 52

def self.from_data(data)
  case data
  when String then new(data)
  when Hash then new(data.fetch("url"), data["path"])
  end
end

Instance Method Details

#==(other) ⇒ Object

Useful in specs



67
68
69
70
71
# File 'lib/cc/config/prepare.rb', line 67

def ==(other)
  other.is_a?(self.class) &&
    other.url == url &&
    other.path == path
end