class

Egui::Ecss::Doc

Inherits Reference < Object

The parsed document: class rules (dotted paths → StyleClass) plus element overrides (Id → ElementEntry). Built by #record_* edits or .parse; written by #to_s.

Constructors

parse(text : String) : Doc

Lenient parse: whatever fully parses becomes a rule; everything else is a one-line STDERR warning (the file is live-edited in text editors — a half-typed declaration must not kill the app).

Source

Class methods

format_value(v : StyleValue) : String

The value spelling: colors as #rrggbbaa (the same lowercase hex StyleSheet#dump uses), whole numbers without the .0.

Source
split_selector(selector : String) : Tuple(String, String | Nil)

"button:hover" → {"button", "hover"}; "button" → {"button", nil}.

Source

Instance methods

class_vars(path : String, state : String | Nil) : StyleVars | Nil

Introspection for specs/tests: the base-or-state bag of a class rule, nil when absent or empty.

Source
classes
Source
clear_element(id : Id) : Bool

Wipe EVERY rule of one element (the inspector's "Reset all").

Source
element(id : Id) : ElementEntry | Nil
Source
elements
Source
empty?
Source
set_class(path : String, state : String | Nil, key : String, value : StyleValue) : Nil

Merge one key into a class rule (creating the class on first touch, like StyleSheet#rule).

Source
set_element(id : Id, name : String | Nil, state : String | Nil, key : String, value : StyleValue) : Nil

Merge one key into an element override (state-scoped like the class rules). name fills the entry's explicit id name when it was only known by its raw value so far. Merge one key into an element override (state-scoped like the class rules). name is required: only explicitly-named widgets are addressable across restarts, so a nil-name (auto-id) edit is silently not recorded — it still applies live through the Context, it just never persists to the file.

Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source
unset_class(path : String, state : String | Nil, key : String) : Bool

Remove one key; true when the document changed. Drops the rule entirely once every bag is empty, so the file never accumulates button { } husks.

Source
unset_element(id : Id, state : String | Nil, key : String) : Bool

Remove one key from an element rule; true when something was actually dropped (empty bags and empty entries go away).

Source