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
-
#x ⇒ Object
@TODO: abstract this into a module.
Methods included from Ish::Utils
Class Method Details
.active ⇒ Object
46 47 48 |
# File 'lib/gameui/marker.rb', line 46 def self.active where( is_active: true ) end |
.permitted_to(profile) ⇒ Object
Active AND [ mine, shared, or public ]
39 40 41 42 43 |
# File 'lib/gameui/marker.rb', line 39 def self.permitted_to profile active.any_of( {is_public: true}, {:shared_profile_ids => profile.id}, {creator_profile_id: profile.id} ) end |
.public ⇒ Object
35 36 37 |
# File 'lib/gameui/marker.rb', line 35 def self.public where( is_public: true ) end |
Instance Method Details
#collect(export_object) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/gameui/marker.rb', line 108 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
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/gameui/marker.rb', line 71 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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gameui/marker.rb', line 91 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 |
#x ⇒ Object
@TODO: abstract this into a module
31 |
# File 'lib/gameui/marker.rb', line 31 field :x, :type => Float, default: 0 |