Class: GrassGis::Mapset

Inherits:
Object
  • Object
show all
Defined in:
lib/grassgis/mapset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Mapset


3
4
5
6
7
8
9
# File 'lib/grassgis/mapset.rb', line 3

def initialize(context)
  @context = context
  @configuration = @context.configuration
  @location = Location.new(@context)
  @mapset = @configuration[:mapset]
  @path = File.join(@location.path, @mapset)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path


11
12
13
# File 'lib/grassgis/mapset.rb', line 11

def path
  @path
end

Instance Method Details

#create!(options = {}) ⇒ Object

Raises:


21
22
23
24
25
26
27
28
29
# File 'lib/grassgis/mapset.rb', line 21

def create!(options = {})
  raise Error, "Mapset #{@mapset} already exists" if exists?
  raise Error, "A file with the same name #{@mapset} exists" if File.exists?(@path)
  raise Error, "Location doesn't exist" unless @location.exists?
  # @context.g.mapet '-c', mapset: @mapset, location: @location.to_s, dbase: @configuration[:gisdbase]
  FileUtils.mkdir_p @path
  permanent = @location.permanent_path
  FileUtils.cp File.join(permanent, 'DEFAULT_WIND'), File.join(@path, 'WIND')
end

#exists?Boolean


17
18
19
# File 'lib/grassgis/mapset.rb', line 17

def exists?
  File.directory?(@path)
end

#to_sObject


13
14
15
# File 'lib/grassgis/mapset.rb', line 13

def to_s
  @mapset
end