Class: AppInfo::Protobuf::Resources::Entry
- Inherits:
-
Object
- Object
- AppInfo::Protobuf::Resources::Entry
- Includes:
- Helper::GenerateClass
- Defined in:
- lib/app_info/protobuf/resources.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #first_value ⇒ Object
-
#initialize(doc, package) ⇒ Entry
constructor
A new instance of Entry.
- #locales ⇒ Object
- #value(locale: '') ⇒ Object
Methods included from Helper::GenerateClass
#create_class, #define_instance_method
Constructor Details
#initialize(doc, package) ⇒ Entry
Returns a new instance of Entry.
126 127 128 129 130 |
# File 'lib/app_info/protobuf/resources.rb', line 126 def initialize(doc, package) @package = package @name = doc.name parse(doc) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
124 125 126 |
# File 'lib/app_info/protobuf/resources.rb', line 124 def name @name end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
124 125 126 |
# File 'lib/app_info/protobuf/resources.rb', line 124 def values @values end |
Class Method Details
Instance Method Details
#first_value ⇒ Object
139 140 141 |
# File 'lib/app_info/protobuf/resources.rb', line 139 def first_value @first_value ||= @values[0] end |
#locales ⇒ Object
143 144 145 |
# File 'lib/app_info/protobuf/resources.rb', line 143 def locales @locales ||= @values.map(&:locale) end |
#value(locale: '') ⇒ Object
132 133 134 135 136 137 |
# File 'lib/app_info/protobuf/resources.rb', line 132 def value(locale: '') values = @values.select { |v| v.locale == locale } return first_value if values.empty? values.size == 1 ? values[0] : values end |