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.



55
56
57
58
59
60
# File 'lib/cc/config/prepare.rb', line 55

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.



46
47
48
# File 'lib/cc/config/prepare.rb', line 46

def path
  @path
end

#urlObject (readonly)

Returns the value of attribute url.



46
47
48
# File 'lib/cc/config/prepare.rb', line 46

def url
  @url
end

Class Method Details

.from_data(data) ⇒ Object



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

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



63
64
65
66
67
# File 'lib/cc/config/prepare.rb', line 63

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