Skip to content

Commit d71ec98

Browse files
dmlaryDavid M. Lary
andauthored
Struct#pretty_print strip blank lines (#3)
* Struct#pretty_print strip blank lines The previous fix resolved the error during inspect, but left blank lines in the output for pad fields. This commit removes those blank lines. --------- Co-authored-by: David M. Lary <[email protected]>
1 parent b0d6d9c commit d71ec98

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/ctypes/struct.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,11 @@ def pretty_print(q) # :nodoc:
512512
"struct {"
513513
end
514514
q.group(4, open, "}") do
515-
q.seplist(self.class.field_layout, -> { q.breakable("") }) do |name, _|
516-
names = name.is_a?(::Array) ? name : [name]
515+
# strip out pad fields
516+
fields = self.class.field_layout.reject do |(_, type)|
517+
type.is_a?(CTypes::Pad)
518+
end
519+
q.seplist(fields, -> { q.breakable("") }) do |name, _|
517520
names.each do |name|
518521
next if name.is_a?(CTypes::Pad)
519522
q.text(".#{name} = ")

lib/ctypes/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# SPDX-License-Identifier: MIT
55

66
module CTypes
7-
VERSION = "0.2.2"
7+
VERSION = "0.2.3"
88
end

0 commit comments

Comments
 (0)