Class: Gameui::Marker
- Inherits:
-
Object
- Object
- Gameui::Marker
- Includes:
- Ish::Utils, Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/gameui/marker.rb
Constant Summary collapse
- ITEM_TYPE_LOCATION =
@TODO: this used to be gameui-location . How is this different from gameui-map ?
'::Gameui::Map'
- ITEM_TYPE_MAP =
'gameui-map'
- ITEM_TYPE_OBJ =
'gameui-obj'
- ITEM_TYPES =
[ ITEM_TYPE_LOCATION, ITEM_TYPE_MAP, ITEM_TYPE_OBJ ]
Class Method Summary collapse
- .active ⇒ Object
-
.permitted_to(profile) ⇒ Object
Active AND [ mine, shared, or public ].
- .public ⇒ Object
Instance Method Summary collapse
- #collect(export_object) ⇒ Object
- #compute_w_h ⇒ Object
- #export_fields ⇒ Object
- #is_3d ⇒ Object
-
#x ⇒ Object
@TODO: abstract this into a module.
Methods included from Ish::Utils
Class Method Details
.active ⇒ Object
52 53 54 |
# File 'lib/gameui/marker.rb', line 52 def self.active where( is_active: true ) end |
.permitted_to(profile) ⇒ Object
Active AND [ mine, shared, or public ]
45 46 47 48 49 |
# File 'lib/gameui/marker.rb', line 45 def self.permitted_to profile active.any_of( {is_public: true}, {:shared_profile_ids => profile.id}, {creator_profile_id: profile.id} ) end |
.public ⇒ Object
41 42 43 |
# File 'lib/gameui/marker.rb', line 41 def self.public where( is_public: true ) end |
Instance Method Details
#collect(export_object) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/gameui/marker.rb', line 114 def collect export_object if image export_object[:image_assets][image.id.to_s] = image.id.to_s end if title_image export_object[:image_assets][title_image.id.to_s] = title_image.id.to_s end if !export_object[:maps][destination.id.to_s] destination.collect export_object end end |
#compute_w_h ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/gameui/marker.rb', line 77 def compute_w_h if !image # @TODO: think about this self.h = self.w = 0 return end begin geo = Paperclip::Geometry.from_file(Paperclip.io_adapters.for(image.image)) self.w = geo.width self.h = geo.height rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e puts! e, 'Could not #compute_w_h' # @TODO: do something with this end end |
#export_fields ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/gameui/marker.rb', line 97 def export_fields %w| centerOffsetX centerOffsetY creator_profile_id deleted_at description destination_id h is_active is_public item_type map_id name ordering url version w x y | end |
#is_3d ⇒ Object
27 28 29 |
# File 'lib/gameui/marker.rb', line 27 def is_3d !!asset3d end |
#x ⇒ Object
@TODO: abstract this into a module
34 |
# File 'lib/gameui/marker.rb', line 34 field :x, :type => Float, default: 0 |