Module: Owrb::HTML::Style
- Defined in:
- lib/owrb.rb
Class Method Summary collapse
- .background(styles) ⇒ Object
- .border(styles) ⇒ Object
- .css(name, *args) ⇒ Object
- .font(styles) ⇒ Object
- .text(styles) ⇒ Object
Class Method Details
.background(styles) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/owrb.rb', line 119 def self.background( styles ) result = [] result.push "background-color: #{styles[ :color ]}" if styles.key?( :color ) result.push "background-image: #{styles[ :image ]}" if styles.key?( :image ) if styles.key?( :linear_gradient ) color = styles[ :linear_gradient ][ :color ] result.push "background-color: #{color[ 0 ]}" result.push "background-image: -webkit-gradient(linear, left top, left bottom, from(#{color[ 0 ]}), to(#{color[ 1 ]}))" result.push "background-image: -webkit-linear-gradient(top, #{color[ 0 ]}, #{color[ 1 ]})" result.push "background-image: -moz-linear-gradient(top, #{color[ 0 ]}, #{color[ 1 ]})" result.push "background-image: -ms-linear-gradient(top, #{color[ 0 ]}, #{color[ 1 ]})" result.push "background-image: -o-linear-gradient(top, #{color[ 0 ]}, #{color[ 1 ]})" result.push "background-image: linear-gradient(to bottom, #{color[ 0 ]}, #{color[ 1 ]})" end result end |
.border(styles) ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/owrb.rb', line 91 def self.border( styles ) result = [] result.push "border: #{styles[ :border ]}" if styles.key?( :border ) if styles.key?( :radius ) result.push "border-radius: #{styles[ :radius ]}" result.push "-webkit-border-radius: #{styles[ :radius ]}" result.push "-moz-border-radius: #{styles[ :radius ]}" end result end |
.css(name, *args) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/owrb.rb', line 83 def self.css( name, *args ) "\#{name} {\n \#{args.collect{|styles| styles.join( \";\\n \" )}.join( \";\\n \" )}\n}\n" end |
.font(styles) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/owrb.rb', line 102 def self.font( styles ) result = [] result.push "font-size: #{styles[ :size ]}" if styles.key?( :size ) result.push "font-weight: #{styles[ :style ]}" if styles.key?( :style ) result.push "font-family: #{styles[ :family ]}" if styles.key?( :family ) result end |
.text(styles) ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/owrb.rb', line 110 def self.text( styles ) result = [] result.push "text-decoration: #{styles[ :decoration ]}" if styles.key?( :decoration ) result.push "text-shadow: #{styles[ :shadow ]}" if styles.key?( :shadow ) result.push "text-align: #{styles[ :align ]}" if styles.key?( :align ) result.push "color: #{styles[ :color ]}" if styles.key?( :color ) result end |