Class: AppInfo::Protobuf::Resources::Package

Inherits:
Object
  • Object
show all
Includes:
Helper::GenerateClass
Defined in:
lib/app_info/protobuf/resources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::GenerateClass

#create_class, #define_instance_method

Constructor Details

#initialize(doc) ⇒ Package

Returns a new instance of Package.



60
61
62
63
# File 'lib/app_info/protobuf/resources.rb', line 60

def initialize(doc)
  @name = doc.package_name
  define_types(doc)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'lib/app_info/protobuf/resources.rb', line 58

def name
  @name
end

#typesObject (readonly)

Returns the value of attribute types.



58
59
60
# File 'lib/app_info/protobuf/resources.rb', line 58

def types
  @types
end

Instance Method Details

#entries(type) ⇒ Object



78
79
80
81
82
83
# File 'lib/app_info/protobuf/resources.rb', line 78

def entries(type)
  method_name = type.to_sym
  return unless respond_to?(method_name)

  send(method_name)
end

#find(name, type: nil, locale: '') ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/app_info/protobuf/resources.rb', line 65

def find(name, type: nil, locale: '')
  match_types(type).each do |type_name|
    next unless respond_to?(type_name.to_sym)
    next unless entries = send(type_name.to_sym).entries

    entries.each do |entry|
      return entry.value(locale: locale) if entry.name == name
    end
  end

  nil
end