-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #2535 replace ostruct with internal implementation
- Loading branch information
1 parent
3cd22b0
commit c275af9
Showing
5 changed files
with
94 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
module Asciidoctor | ||
module PDF | ||
class ThemeData | ||
attr_reader :table | ||
|
||
def initialize data = nil | ||
@table = (data || {}).transform_keys(&:to_sym) | ||
end | ||
|
||
def [] name | ||
@table[name.to_sym] | ||
end | ||
|
||
def []= name, value | ||
@table[name.to_sym] = value | ||
end | ||
|
||
def each_pair &block | ||
@table.each_pair(&block) | ||
end | ||
|
||
def eql? other | ||
@table.to_h.eql? other.to_h | ||
end | ||
|
||
def delete_field name | ||
@table.delete name | ||
end | ||
|
||
def dup | ||
ThemeData.new @table | ||
end | ||
|
||
def method_missing name, *args | ||
if (name_str = name.to_s).end_with? '=' | ||
@table[name_str.chop.to_sym] = args[0] | ||
else | ||
@table[name] | ||
end | ||
end | ||
|
||
def respond_to? name, _include_all = false | ||
@table.key? name.to_sym | ||
end | ||
|
||
def respond_to_missing? name, _include_all = false | ||
@table.key? name.to_sym | ||
end | ||
|
||
def to_h | ||
@table | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters