tablelists 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tablelists.rb +55 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c765b38619f1c10c08c5e526f4ccd9f3d87a6cf2
4
+ data.tar.gz: b4f5e2f10ae2bddf2f40c1a303ca3c43aba5f50d
5
+ SHA512:
6
+ metadata.gz: 4209b3ee8e363650714eccd7b10193e0334bf6a45cf989e1f4ac4bb8f6a3739931f03528f96d97e270653476f969a504cad9b074e7645a4aa632526729ee9c2b
7
+ data.tar.gz: 787e0ecad2830c492995c4e15b200db6805d43707bf89252e25215ebafccb59765843df5e37bccfee226c37e732640876c7a16c06b0eeb73646ecaaf04c98db1
data/lib/tablelists.rb ADDED
@@ -0,0 +1,55 @@
1
+ class ActiveRecord
2
+ def filting( page , quality_of_elements , category)
3
+ puts category[0]
4
+ # Qualety of elements which will be shows on page
5
+ elemants_int = quality_of_elements.to_i
6
+ elemants_float = quality_of_elements.to_f
7
+ #
8
+ # @category = category
9
+ # Number of page.
10
+ @number = page.to_i
11
+ #
12
+ # How match pages can be and validations.
13
+ g_length = self.all.length;
14
+ float_pages = g_length/elemants_float
15
+ int_pages = g_length/elemants_int
16
+ if (float_pages) > int_pages
17
+ pages = int_pages + 1
18
+ elsif (float_pages) <= int_pages
19
+ pages = int_pages
20
+ end
21
+ if @number > pages || @number < 1
22
+ @number = 1
23
+ end
24
+ if category.length > 0
25
+ image = self.where(categories(category)).last(elemants_int*@number)
26
+ else
27
+ image = self.last(elemants_int*@number)
28
+ end
29
+ if image.length/elemants_float == image.length/elemants_int
30
+ @galery = image[0..elemants_int-1]
31
+ elsif image.length/elemants_float > image.length/elemants_int
32
+ @galery = image[0..(image.length - elemants_int*(@number-1)-1)]
33
+ end
34
+ end
35
+
36
+ def categories(category)
37
+ x = ""
38
+ keys = category.keys
39
+ for i in 0..category.length-1
40
+ x << "#{keys[i]} = '#{category[keys[i]]}' "
41
+ if (category.length-1) == i
42
+ break;
43
+ end
44
+ x << "AND "
45
+ i += 1;
46
+ end
47
+ return x;
48
+ end
49
+
50
+ # def category_loop
51
+ # for i in 0..5
52
+ #
53
+ # end
54
+ # end
55
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tablelists
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Chernovsky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A list of elements in table
14
+ email: daniel.chernovsky@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/tablelists.rb
20
+ homepage: http://rubygems.org/gems/tableLists
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.6.7
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: ''
44
+ test_files: []