Class: CTioga2::Graphics::Styles::StyleSheet::Bucket

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/graphics/styles/stylesheet.rb

Overview

A style bucket, a hash ‘key’ => ‘value’ associated with a unique xpath

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xp) ⇒ Bucket

Returns a new instance of Bucket.



211
212
213
214
215
# File 'lib/ctioga2/graphics/styles/stylesheet.rb', line 211

def initialize(xp)
  @xname = xp
  @xpath = XPath.from_text(xp)
  @style = {}
end

Instance Attribute Details

#styleObject

The style information (a string->string hash).

Not that it can actually be a string->typed stuff, since most types accept that !



203
204
205
# File 'lib/ctioga2/graphics/styles/stylesheet.rb', line 203

def style
  @style
end

#xnameObject

The xpath text initially used



209
210
211
# File 'lib/ctioga2/graphics/styles/stylesheet.rb', line 209

def xname
  @xname
end

#xpathObject

All the XPath associated with this style information



206
207
208
# File 'lib/ctioga2/graphics/styles/stylesheet.rb', line 206

def xpath
  @xpath
end

Instance Method Details

#matches?(obj) ⇒ Boolean

Returns:

  • (Boolean)


217
218
219
220
221
222
223
# File 'lib/ctioga2/graphics/styles/stylesheet.rb', line 217

def matches?(obj)
  if @xpath.matches?(obj)
    return true
  else
    return false
  end
end

#normalized_styleObject

Returns the style, but with all the options normalized to lowercase and without



227
228
229
230
231
232
233
# File 'lib/ctioga2/graphics/styles/stylesheet.rb', line 227

def normalized_style
  stl = {}
  for k,v in @style
    stl[k.gsub(/-/,"_").downcase] = v
  end
  return stl
end