Class: Tolk::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/tolk/export.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Export

Returns a new instance of Export.



5
6
7
8
9
# File 'lib/tolk/export.rb', line 5

def initialize(args)
  @name = args.fetch(:name, '')
  @data = args.fetch(:data, {})
  @destination = args.fetch(:destination, self.class.dump_path)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/tolk/export.rb', line 3

def data
  @data
end

#destinationObject (readonly)

Returns the value of attribute destination.



3
4
5
# File 'lib/tolk/export.rb', line 3

def destination
  @destination
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/tolk/export.rb', line 3

def name
  @name
end

Class Method Details

.dump(args) ⇒ Object



18
19
20
# File 'lib/tolk/export.rb', line 18

def dump(args)
  new(args).dump
end

.dump_pathObject



22
23
24
# File 'lib/tolk/export.rb', line 22

def dump_path
  Tolk::Locale._dump_path
end

Instance Method Details

#dumpObject



11
12
13
14
15
# File 'lib/tolk/export.rb', line 11

def dump
  File.open("#{destination}/#{name}.yml", "w+") do |file|
    file.write(Tolk::YAML.dump(data))
  end
end