Class: Interscript::DSL::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/interscript/dsl/metadata.rb

Constant Summary collapse

STANDARD_STRING_KEYS =
%i{authority_id id
language source_script destination_script
name creation_date adoption_date description
character source confirmation_date original_description}
STANDARD_ARRAY_KEYS =
%i{notes implementation_notes original_notes url}
NONSTANDARD_KEYS =
%i{special_rules}
NECESSARY_KEYS =
%i{name language source_script destination_script}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml: false, map_name: "", library: true, &block) ⇒ Metadata

Returns a new instance of Metadata.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/interscript/dsl/metadata.rb', line 6

def initialize(yaml: false, map_name: "", library: true, &block)
  raise Interscript::MapLogicError, "Can't evaluate metadata from Ruby context" unless yaml
  @map_name = map_name
  @node = Interscript::Node::MetaData.new
  self.instance_exec(&block)
  @node[:nonstandard] = {}

  NECESSARY_KEYS.each do |i|
    unless @node.data.key? i
      warn "[#{@map_name}] Necessary key #{i} wasn't defined. Defaulting to an empty string"
      @node[i] = ""
    end
  end unless library
end

Instance Attribute Details

#nodeObject

Returns the value of attribute node.



4
5
6
# File 'lib/interscript/dsl/metadata.rb', line 4

def node
  @node
end