Class: DataPackage::LocalResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/datapackage/resource.rb

Instance Method Summary collapse

Methods inherited from Resource

file_exists?, is_url?, load

Constructor Details

#initialize(resource, base_path = '') ⇒ LocalResource

Returns a new instance of LocalResource.



45
46
47
48
49
# File 'lib/datapackage/resource.rb', line 45

def initialize(resource, base_path = '')
  @base_path = base_path
  @path = resource['path']
  super
end

Instance Method Details

#dataObject



51
52
53
54
# File 'lib/datapackage/resource.rb', line 51

def data
  @path = File.join(@base_path, @path) if @base_path != ''
  open(@path).read
end