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, #table

Constructor Details

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

Returns a new instance of LocalResource.



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

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

Instance Method Details

#dataObject



55
56
57
58
# File 'lib/datapackage/resource.rb', line 55

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