Module: ClassNode
- Included in:
- AlbumNode, BlockAvatarNode, ChatNode, CommentNode, FavoriteAlbumNode, FavoriteNode, FollowerNode, FollowerTagNode, Followerx2GroupNode, FollowingGroupNode, FollowingNode, FollowingTagNode, Followingx2GroupNode, InboxNode, LinkmanNode, LoverAlbumNode, LoverNode, OutboxNode, TrackBlockNode, TrackInRecordNode, TrackNode, TrackPictureNode, TrackRecordNode, TrackRichNode, TrackSetNode, TrackSetRichNode, UserTagNode
- Defined in:
- lib/extenders/class_node.rb
Instance Method Summary collapse
Instance Method Details
#seek(key) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/extenders/class_node.rb', line 5 def seek(key) unless @sorted_nodes sorted_nodes, node_x_class_nodes = [], {} self.select('node, class_name, table_name').order('node').each do |class_node| sorted_nodes << class_node.node node_x_class_nodes[class_node.node] = class_node end @sorted_nodes, @node_x_class_nodes = sorted_nodes, node_x_class_nodes end node = @sorted_nodes.bsearch{|node| node >= Zlib::crc32(key.to_s)} || @sorted_nodes.first @node_x_class_nodes[node] end |