Class: Declaration
- Inherits:
-
Object
- Object
- Declaration
- Defined in:
- lib/csspress/declaration.rb
Overview
Declaration represents a declaration in a style sheet rule. It is composed of a property and a value. The property must be valid.
Example:
d = declaration.new ( "border-color", "blue" )
puts d.property #=> "border-color"
puts d.value #=> "blue"
Defined Under Namespace
Classes: PropertyError
Constant Summary collapse
- VALID_PROPERTIES =
Properties for CSS1 to CSS3
%w( alignment-adjust alignment-baseline appearance azimuth background background-attachment background-break background-clip background-color background-image background-origin background-position background-repeat background-size baseline-shift binding bookmark-label bookmark-level bookmark-target border border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-break border-collapse border-color border-image border-left border-left-color border-left-style border-left-width border-length border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-align box-direction box-flex box-flex-group box-lines box-orient box-pack box-shadow box-sizing caption-side clear clip color color-profile column-break-after column-break-before column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width columns content counter-increment counter-reset crop cue cue-after cue-before cursor direction display dominant-baseline drop-initial-after-adjust drop-initial-after-align drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value elevation empty-cells fit fit-position float float-offset font font-effect font-emphasize font-emphasize-position font-emphasize-style font-family font-size font-size-adjust font-smooth font-stretch font-style font-variant font-weight grid-columns grid-rows hanging-punctuation height hyphenate-after hyphenate-before hyphenate-character hyphenate-lines hyphenate-resource hyphens icon image-orientation image-resolution inline-box-align left letter-spacing line-height line-stacking line-stacking-ruby line-stacking-shift line-stacking-strategy list-style list-style-image list-style-position list-style-type margin margin-bottom margin-left margin-right margin-top mark mark-after mark-before marker-offset marks marquee-direction marquee-loop marquee-speed marquee-style max-height max-width min-height min-width move-to nav-down nav-index nav-left nav-right nav-up opacity orphans outline outline-color outline-offset outline-style outline-width overflow overflow-style overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page page-break-after page-break-before page-break-inside page-policy pause pause-after pause-before phonemes pitch pitch-range play-during position presentation-level punctuation-trim quotes rendering-intent resize rest rest-after rest-before richness right rotation rotation-point ruby-align ruby-overhang ruby-position ruby-span size speak speak-header speak-numeral speak-punctuation speech-rate stress string-set tab-side table-layout target target-name target-new target-position text-align text-align-last text-decoration text-emphasis text-height text-indent text-justify text-outline text-replace text-shadow text-transform text-wrap top unicode-bidi vertical-align visibility voice-balance voice-duration voice-family voice-pitch voice-pitch-range voice-rate voice-stress voice-volume volume white-space white-space-collapse widows width word-break word-spacing word-wrap z-index )
Instance Attribute Summary collapse
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(property, value) ⇒ Declaration
constructor
A new instance of Declaration.
- #to_s ⇒ Object
Constructor Details
#initialize(property, value) ⇒ Declaration
Returns a new instance of Declaration.
61 62 63 64 65 |
# File 'lib/csspress/declaration.rb', line 61 def initialize(property, value) raise PropertyError unless VALID_PROPERTIES.include?(property) @property = property @value = value end |
Instance Attribute Details
#property ⇒ Object (readonly)
Returns the value of attribute property.
22 23 24 |
# File 'lib/csspress/declaration.rb', line 22 def property @property end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
22 23 24 |
# File 'lib/csspress/declaration.rb', line 22 def value @value end |
Instance Method Details
#to_s ⇒ Object
67 68 69 |
# File 'lib/csspress/declaration.rb', line 67 def to_s "#{@property}:#{@value}" end |