Class: Prismic::Fragments::Color
- Defined in:
 - lib/prismic/fragments/color.rb
 
Instance Attribute Summary collapse
- 
  
    
      #value  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute value.
 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #as_html(link_resolver = nil)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Generate an HTML representation of the fragment.
 - 
  
    
      #asRGB  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the RGB values in a Hash.
 - 
  
    
      #initialize(value)  ⇒ Color 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Color.
 
Methods inherited from Fragment
Constructor Details
#initialize(value) ⇒ Color
Returns a new instance of Color
      7 8 9  | 
    
      # File 'lib/prismic/fragments/color.rb', line 7 def initialize(value) @value = value end  | 
  
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value
      5 6 7  | 
    
      # File 'lib/prismic/fragments/color.rb', line 5 def value @value end  | 
  
Class Method Details
.asRGB(value) ⇒ Object
      21 22 23 24 25 26 27  | 
    
      # 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  | 
  
.valid?(value) ⇒ Boolean
      39 40 41  | 
    
      # File 'lib/prismic/fragments/color.rb', line 39 def self.valid?(value) /(\h{2})(\h{2})(\h{2})/ === value end  | 
  
Instance Method Details
#as_html(link_resolver = nil) ⇒ String
Generate an HTML representation of the fragment
      35 36 37  | 
    
      # File 'lib/prismic/fragments/color.rb', line 35 def as_html(link_resolver=nil) %(<span class="color">##@value</span>) end  |