img_return 1.0.7 → 1.0.9

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 +4 -4
  2. data/lib/img_return.rb +19 -39
  3. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0bab96b231abdf2547e20b0fc40b22252960bf5
4
- data.tar.gz: 9c8445b808d5ea2d62a763e8ff1d0a9920713cd0
3
+ metadata.gz: f80f6a186f111a35e1d15fb08633d7405cd6c5a0
4
+ data.tar.gz: 8da6fddfae7c19e3c52343696491fe9b1512c821
5
5
  SHA512:
6
- metadata.gz: 065471630407a7a0fddeb979e3e2e72441f36b5bdb6323215853f203aaedc83dabc343d9f51150bfc749d611868f2014cce1201578e589351f96a712f5d069c2
7
- data.tar.gz: 579cac646baf6801c16d8728ec3c06cf2f5e158dba4ff012e85875b36ab7bf3d17c243dd97ee01fbd9bb8a1dc7f67c042163c3bc46b0efbfb07041fd823d7bad
6
+ metadata.gz: 1ce8b6cbfee10d9eae8fc5ed02d44c0b48e7b023c6c61ca206b533cf638c4cec7c2ece49b1bcd7fb243dbd4a44ee0f77f56e1932b075f4a968395995c4052e4f
7
+ data.tar.gz: 9c8ea5d2e606b7b0369fe996d56deb3794a049b45f602e0fd5ef01506aa0701974e55631926793a9f7807d78fb978ef0184d70272c7746389969e547a01c6a9a
data/lib/img_return.rb CHANGED
@@ -1,64 +1,44 @@
1
1
  require "fileutils"
2
2
 
3
3
  module Return_Img
4
- Colors = {:AliceBlue => "#F0F8FF", :AntiqueWhite => "#FAEBD7", :Aqua => "#00FFFF", :Aquamarine => "#7FFFD4", :Azure => "#F0FFFF", :Beige => "#F5F5DC", :Bisque => "#FFE4C4", :Black => "#000000", :BlanchedAlmond => "#FFEBCD", :Blue => "#0000FF", :BlueViolet => "#8A2BE2", :Brown => "#A52A2A", :BurlyWood => "#DEB887", :CadetBlue => "#5F9EA0", :Chartreuse => "#7FFF00", :Chocolate => "#D2691E", :Coral => "#FF7F50", :CornflowerBlue => "#6495ED", :Cornsilk => "#FFF8DC", :Crimson => "#DC143C", :Cyan => "#00FFFF", :DarkBlue => "#00008B"}
5
- # Gets array and returns one random element from the array.
6
- def self.return_random(arry)
7
- raise TypeError, "Argument must be an array." if arry.class != Array
4
+ def self.random(arry)
8
5
  random_img = Random.new
9
- ri = random_img.rand(0..arry.size)
6
+ ri = random_img.rand(0...arry.size)
10
7
  arry.each_index{|ei|
11
8
  @return_background_img = arry[ri] if ei == ri
12
9
  }
13
10
  return @return_background_img
14
11
  end
15
- def self.write_css_file(path, css_code)
16
- raise TypeError, "First argument 'path' must be a String." if path.class != String
17
- raise TypeError, "Second argument 'css_code' must be a String." if css_code.class != String
12
+ def self.write(path, css_code)
18
13
  File.open("#{path}.css", 'w'){|fp|
19
14
  fp.puts(css_code)
20
15
  }
21
16
  return css_code
22
17
  end
23
- class Background_Image
24
- def list_images(dir)
25
- raise TypeError, "dir must be a String." if dir.class != String
26
- possible_background_images = []
27
- if dir == "."
28
- FileUtils.cd("app/assets/images") do
29
- Dir.entries(".").each{|en|
30
- possible_background_images.push(en) if File.extname(en) == ".png" || File.extname(en) == ".jpg" || File.extname(en) == ".tiff"
31
- }
32
- end
33
- else
34
- FileUtils.cd("app/assets/images/#{dir}") do
35
- Dir.entries(".").each{|en|
36
- possible_background_images.push(en) if File.extname(en) == ".png" || File.extname(en) == ".jpg" || File.extname(en) == ".tiff"
37
- }
38
- end
39
- end
40
- return possible_background_images
18
+ class Image
19
+ def list(dir)
20
+ images = []
21
+ FileUtils.cd(dir) do
22
+ Dir.entries(".").each{|en|
23
+ images.push(en) if File.extname(en) == ".png" || File.extname(en) == ".jpg" || File.extname(en) == ".tiff"
24
+ }
25
+ end
26
+ return images
41
27
  end
42
- def write_css_file(bg_img, css_filename)
43
- raise TypeError, "First argument 'bg_img' must be a String." if bg_img.class != String
44
- raise TypeError, "Second argument 'css_filename' must be a String." if css_filename.class != String
45
- background_css_code = "body {
46
- background-image: url('#{bg_img}');
28
+ def write(img_path, css_file_path)
29
+ css_code = "body {
30
+ background-image: url('#{img_path}');
47
31
  background-repeat:no-repeat;
48
32
  background-size:cover;
49
33
  }"
50
- Return_Img.write_css_file("app/assets/stylesheets/#{css_filename}", "#{background_css_code}")
51
- return background_css_code
34
+ Return_Img.write(css_file_path, css_code)
52
35
  end
53
- def self.render_color_style(element, style, css_filename)
54
- raise TypeError, "First argument 'element' must be a String." if element.class != String
55
- raise TypeError, "Second argument 'style' must be a String." if style.class != String
56
- raise TypeError, "Third argument 'css_filename' must be a String." if css_filename.class != String
36
+ def self.render_color_style(element, style, css_filename_path)
37
+ warn Kernel.caller.first + "render_color_style is a deprecated class method. Make your own with Return_Img.write()"
57
38
  css_color_code = "#{element} {
58
39
  background-color: #{style};
59
40
  }"
60
- Return_Img.write_css_file("app/assets/stylesheets/#{css_filename}", "#{css_color_code}")
61
- return css_color_code
41
+ Return_Img.write(css_filename_path, css_color_code)
62
42
  end
63
43
  end
64
44
  end
metadata CHANGED
@@ -1,16 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: img_return
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralph Desir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-22 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A gem made for returning picture files for rails views.
13
+ description: img_return is a gem designed to return random images and colors. This
14
+ gem was created with the idea of returning a different image or color to a cascading
15
+ style sheet. For the effect of having a different image return to the browser ever
16
+ refresh or visit to the web page. Also in mind was the idea of expedition, by that
17
+ I mean expediting a lot of the markup work (HTML/CSS) with this gems helper methods.
14
18
  email: battleroundscool@gmail.com
15
19
  executables: []
16
20
  extensions: []