Class: TrackBlockOrigin
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TrackBlockOrigin
- Extended by:
- TrackBlockExtender
- Defined in:
- lib/ting_model/track_block_origin.rb
Direct Known Subclasses
TrackBlock, TrackBlock0, TrackBlock1, TrackBlock10, TrackBlock11, TrackBlock12, TrackBlock13, TrackBlock14, TrackBlock15, TrackBlock16, TrackBlock17, TrackBlock18, TrackBlock19, TrackBlock2, TrackBlock20, TrackBlock21, TrackBlock22, TrackBlock23, TrackBlock24, TrackBlock25, TrackBlock26, TrackBlock27, TrackBlock28, TrackBlock29, TrackBlock3, TrackBlock30, TrackBlock31, TrackBlock32, TrackBlock33, TrackBlock34, TrackBlock35, TrackBlock36, TrackBlock37, TrackBlock38, TrackBlock39, TrackBlock4, TrackBlock40, TrackBlock41, TrackBlock42, TrackBlock43, TrackBlock44, TrackBlock45, TrackBlock46, TrackBlock47, TrackBlock48, TrackBlock49, TrackBlock5, TrackBlock50, TrackBlock51, TrackBlock52, TrackBlock53, TrackBlock54, TrackBlock55, TrackBlock56, TrackBlock57, TrackBlock58, TrackBlock59, TrackBlock6, TrackBlock60, TrackBlock61, TrackBlock62, TrackBlock63, TrackBlock64, TrackBlock65, TrackBlock66, TrackBlock67, TrackBlock68, TrackBlock69, TrackBlock7, TrackBlock70, TrackBlock71, TrackBlock72, TrackBlock73, TrackBlock74, TrackBlock75, TrackBlock76, TrackBlock77, TrackBlock78, TrackBlock79, TrackBlock8, TrackBlock80, TrackBlock81, TrackBlock82, TrackBlock83, TrackBlock84, TrackBlock85, TrackBlock86, TrackBlock87, TrackBlock88, TrackBlock89, TrackBlock9, TrackBlock90, TrackBlock91, TrackBlock92, TrackBlock93, TrackBlock94, TrackBlock95, TrackBlock96, TrackBlock97, TrackBlock98, TrackBlock99
Constant Summary collapse
- TRACK_MAX_BLOCKS =
播放彩条分块
30
- MIN_SECONDS_PER_BLOCK =
彩条分块每块默认几秒
2
Instance Method Summary collapse
Methods included from TrackBlockExtender
Instance Method Details
#get_block_idx_by_second(second) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/ting_model/track_block_origin.rb', line 28 def get_block_idx_by_second(second) if second second = second.to_i next_flag = self.flags.split(',').map{|s| s.to_f}.index{|x| x > second} return next_flag ? next_flag - 1 : self.blocks - 1 end nil end |
#increase_by_second(second, inc = 1) ⇒ Object
更新评论数
39 40 41 42 43 44 45 46 |
# File 'lib/ting_model/track_block_origin.rb', line 39 def increase_by_second(second, inc = 1) idx = self.get_block_idx_by_second(second) if idx col = "b#{idx}" count = self.send(col) + inc self.update_attributes(col.to_sym => (count >= 0 ? count : 0)) end end |