Class: GrassGis::Mapset
- Inherits:
-
Object
- Object
- GrassGis::Mapset
- Defined in:
- lib/grassgis/mapset.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #create!(options = {}) ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(context) ⇒ Mapset
constructor
A new instance of Mapset.
- #to_s ⇒ Object
Constructor Details
#initialize(context) ⇒ Mapset
Returns a new instance of 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
#path ⇒ Object (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
21 22 23 24 25 26 27 28 29 |
# File 'lib/grassgis/mapset.rb', line 21 def create!( = {}) 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_s ⇒ Object
13 14 15 |
# File 'lib/grassgis/mapset.rb', line 13 def to_s @mapset end |