Skip to content

Commit

Permalink
fix compatibility with Ruby 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Jun 22, 2015
1 parent c65a866 commit f3a5653
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def arrange_images fragments
end

if ::RUBY_MIN_VERSION_2
::Prawn::Text::Formatted::Box.prepend InlineImageArranger
class ::Prawn::Text::Formatted::Box
prepend InlineImageArranger
end
else
::Prawn::Text::Formatted::Box.extensions << InlineImageArranger
end
Expand Down
17 changes: 9 additions & 8 deletions lib/asciidoctor-pdf/prawn_ext/formatted_text/fragment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ def descender= val
end
end

if ::RUBY_MIN_VERSION_2
::Prawn::Text::Formatted::Fragment.prepend Fragment
else
# NOTE it's necessary to first remove the accessor methods we are replacing
::Prawn::Text::Formatted::Fragment.__send__ :remove_method, :ascender=
::Prawn::Text::Formatted::Fragment.__send__ :remove_method, :descender=
# NOTE we use __send__ since :include wasn't public until Ruby 2.0
::Prawn::Text::Formatted::Fragment.__send__ :include, Fragment
class ::Prawn::Text::Formatted::Fragment
if ::RUBY_MIN_VERSION_2
prepend Fragment
else
# NOTE it's necessary to remove the accessor methods or else they won't get replaced
remove_method :ascender=
remove_method :descender=
include Fragment
end
end
end
end
Expand Down

0 comments on commit f3a5653

Please sign in to comment.