class Prismic::Fragments::Color
Attributes
value[RW]
Public Class Methods
asRGB(value)
click to toggle source
# File lib/prismic/fragments/color.rb, line 21 def self.asRGB(value) { 'red' => value[0..1].to_i(16), 'green' => value[2..3].to_i(16), 'blue' => value[4..5].to_i(16) } end
new(value)
click to toggle source
# File lib/prismic/fragments/color.rb, line 7 def initialize(value) @value = value end
valid?(value)
click to toggle source
# File lib/prismic/fragments/color.rb, line 39 def self.valid?(value) /(\h{2})(\h{2})(\h{2})/ === value end
Public Instance Methods
asRGB()
click to toggle source
Returns the RGB values in a Hash
@example
color.asRGB # => {'red' => 123, 'green' => 123, 'blue' => 123}
@return [Hash]
# File lib/prismic/fragments/color.rb, line 17 def asRGB Fragments::Color.asRGB(@value) end
as_html(link_resolver=nil)
click to toggle source
Generate an HTML representation of the fragment
@param link_resolver [LinkResolver] The LinkResolver
used to build
application's specific URL
@return [String] the HTML representation
# File lib/prismic/fragments/color.rb, line 35 def as_html(link_resolver=nil) %(<span class="color">##@value</span>) end