Class: Cukunity::Unity::Component
- Inherits:
-
JSONContainer
- Object
- JSONContainer
- Cukunity::Unity::Component
- Defined in:
- lib/cukunity/unity/component.rb
Instance Attribute Summary collapse
-
#gameobject ⇒ Object
readonly
Returns the value of attribute gameobject.
Attributes inherited from JSONContainer
Instance Method Summary collapse
- #has_hint?(*args) ⇒ Boolean
- #hint(*args) ⇒ Object
- #hints(options = {}) ⇒ Object
-
#initialize(json, gameobject) ⇒ Component
constructor
A new instance of Component.
Methods inherited from JSONContainer
#has_key?, #keys, #method_missing, #to_s, #value_of
Methods included from Cukunity::Utils
#check_timeout, #merge_options, #restrict_options, #to_options, #wait_connectivity
Constructor Details
#initialize(json, gameobject) ⇒ Component
Returns a new instance of Component.
6 7 8 9 |
# File 'lib/cukunity/unity/component.rb', line 6 def initialize(json, gameobject) super(json) @gameobject = gameobject end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cukunity::Unity::JSONContainer
Instance Attribute Details
#gameobject ⇒ Object (readonly)
Returns the value of attribute gameobject.
4 5 6 |
# File 'lib/cukunity/unity/component.rb', line 4 def gameobject @gameobject end |
Instance Method Details
#has_hint?(*args) ⇒ Boolean
15 16 17 |
# File 'lib/cukunity/unity/component.rb', line 15 def has_hint?(*args) !hint(*args).nil? end |
#hint(*args) ⇒ Object
11 12 13 |
# File 'lib/cukunity/unity/component.rb', line 11 def hint(*args) hints(*args).first end |
#hints(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cukunity/unity/component.rb', line 19 def hints( = {}) # memoize all hints if @hints.nil? @hints = (value_of('.hints') || []).inject([]) do |hints, json| type = json[0] values = json[1] hints + values.map do |json| Unity::Hint.new(json, type, self) end end end = (, { :type => nil }) return @hints if [:type].nil? # select desired hints @hints.select do |hint| [:type].to_s == hint.type end end |