Skip to content

Commit

Permalink
Convert to unit classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarring committed Aug 9, 2024
1 parent 4dc59b0 commit 23e2217
Show file tree
Hide file tree
Showing 10 changed files with 747 additions and 749 deletions.
6 changes: 3 additions & 3 deletions lib/PDF/Tags.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class PDF::Tags:ver<0.1.16> {
my ($owner, $key) = att-owner(.key);
%atts-by-owner{$owner}{$key} = .value;
}
my @atts = %atts-by-owner.keys.sort.map: -> $owner {
my PDF::Attributes() @atts = %atts-by-owner.keys.sort.map: -> $owner {
my %atts = %atts-by-owner{$owner};
%atts<O> = $owner;
PDF::Attributes.COERCE: %atts
%atts;
}

if @atts {
Expand All @@ -79,7 +79,7 @@ class PDF::Tags:ver<0.1.16> {
}

method create(
PDF::Class:D :$pdf,
PDF::Class:D :$pdf!,
PDF::StructTreeRoot() :$cos = { :Type( :name<StructTreeRoot> )},
:%role-map,
:%class-map,
Expand Down
46 changes: 24 additions & 22 deletions lib/PDF/Tags/Attr.rakumod
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
use PDF::Tags::Node;
#| Attribute node
class PDF::Tags::Attr
is PDF::Tags::Node {
use PDF::Tags::Node::Parent;
use Method::Also;

has PDF::Tags::Node::Parent $.parent is rw;
submethod TWEAK(Pair :$cos!) {
self.set-cos($cos);
}
method xpath {
my Str $xpath = .xpath with $!parent;
$xpath ~= '@' ~ self.name;
$xpath;
}
multi sub to-str(@a) { @a».Str.join: ' '}
multi sub to-str($_) { .Str}
method name { $.cos.key }
method value { $.cos.value }
method text is also<Str> { to-str($.value) }
method gist { [~] '@', $.cos.key, '=', $.text }
method cos(--> Pair) is also<kv> { callsame() }
unit class PDF::Tags::Attr;

use PDF::Tags::Node;
also is PDF::Tags::Node;

use PDF::Tags::Node::Parent;
use Method::Also;

has PDF::Tags::Node::Parent $.parent is rw;
submethod TWEAK(Pair :$cos!) {
self.set-cos($cos);
}
method xpath {
my Str $xpath = .xpath with $!parent;
$xpath ~= '@' ~ self.name;
$xpath;
}
multi sub to-str(@a) { @a».Str.join: ' '}
multi sub to-str($_) { .Str}
method name { $.cos.key }
method value { $.cos.value }
method text is also<Str> { to-str($.value) }
method gist { [~] '@', $.cos.key, '=', $.text }
method cos(--> Pair) is also<kv> { callsame() }


=begin pod
Expand Down
Loading

0 comments on commit 23e2217

Please sign in to comment.