class Object

Constants

ART_CSS_VERSION

Public Instance Methods

return_array_of_images(dir) click to toggle source
# File lib/art_css.rb, line 54
def return_array_of_images(dir)
  images = []
  FileUtils.cd(dir) do
    Dir.entries(".").each do |entry|
      images.push(entry) if File.extname(entry) == ".png" || File.extname(entry) == ".jpg" || File.extname(entry) == ".gif"
    end
  end

  images
end
return_random_image(array) click to toggle source
# File lib/art_css.rb, line 4
def return_random_image(array)
  random_image = Random.new
  random_image  = random_image.rand(0...array.size)
  array.each_index do |index|
    random_image = array[random_image] if index == random_image
  end

  random_image
end
write_background_with_four_images_css(input_path1, input_path2, input_path3, input_path4, section = "body", output_path) click to toggle source
# File lib/art_css.rb, line 46
def write_background_with_four_images_css(input_path1, input_path2, input_path3, input_path4, section = "body", output_path)
  css_code = "#{section} {
      background-image: url('#{input_path1}'), url('#{input_path2}'), url('#{input_path3}'), url('#{input_path4}'); 
}"

  write_css(output_path, css_code)
end
write_background_with_three_images_css(input_path1, input_path2, input_path3, section = "body", output_path) click to toggle source
# File lib/art_css.rb, line 38
def write_background_with_three_images_css(input_path1, input_path2, input_path3, section = "body", output_path)
  css_code = "#{section} {
      background-image: url('#{input_path1}'), url('#{input_path2}'), url('#{input_path3}'); 
}"

  write_css(output_path, css_code)
end
write_background_with_two_images_css(input_path1, input_path2, section = "body", output_path) click to toggle source
# File lib/art_css.rb, line 30
def write_background_with_two_images_css(input_path1, input_path2, section = "body", output_path)
  css_code = "#{section} {
      background-image: url('#{input_path1}'), url('#{input_path2}');
}"

  write_css(output_path, css_code)
end
write_css(output_path, css_code) click to toggle source
# File lib/art_css.rb, line 14
def write_css(output_path, css_code)
  File.open("#{output_path}.css", 'w') do |file|
    file.puts(css_code) 
  end
end
write_fullscreen_background_no_repeat_css(input_path, section = "body", output_path) click to toggle source
# File lib/art_css.rb, line 20
def write_fullscreen_background_no_repeat_css(input_path, section = "body", output_path)
  css_code = "#{section} {
      background-image: url('#{input_path}'); 
      background-repeat:no-repeat;
      background-size:cover;
}"

  write_css(output_path, css_code)
end