Class: Txgh::Config::TxConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh/config/tx_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources, lang_map) ⇒ TxConfig

Returns a new instance of TxConfig.



57
58
59
60
# File 'lib/txgh/config/tx_config.rb', line 57

def initialize(resources, lang_map)
  @resources = resources
  @lang_map = lang_map
end

Instance Attribute Details

#lang_mapObject (readonly)

Returns the value of attribute lang_map.



55
56
57
# File 'lib/txgh/config/tx_config.rb', line 55

def lang_map
  @lang_map
end

#resourcesObject (readonly)

Returns the value of attribute resources.



55
56
57
# File 'lib/txgh/config/tx_config.rb', line 55

def resources
  @resources
end

Class Method Details

.load(contents) ⇒ Object



10
11
12
13
# File 'lib/txgh/config/tx_config.rb', line 10

def load(contents)
  config = Txgh::ParseConfig.load(contents)
  parse(config)
end

.load_file(path) ⇒ Object



5
6
7
8
# File 'lib/txgh/config/tx_config.rb', line 5

def load_file(path)
  config = Txgh::ParseConfig.load_file(path)
  parse(config)
end

Instance Method Details

#resource(slug, branch = nil) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/txgh/config/tx_config.rb', line 62

def resource(slug, branch = nil)
  if branch
    TxBranchResource.find(self, slug, branch)
  else
    resources.find do |resource|
      resource.resource_slug == slug
    end
  end
end

#to_hObject



72
73
74
# File 'lib/txgh/config/tx_config.rb', line 72

def to_h
  { resources: resources.map(&:to_h), lang_map: lang_map }
end