Sha256: 5040981058cb64ea651323b098158596fefcbbd8e47b757f34edb2ceea05076b
Contents?: true
Size: 786 Bytes
Versions: 1
Compression:
Stored size: 786 Bytes
Contents
# frozen_string_literal: true require 'json' module Cosensee # for Line Line = Data.define(:content, :parsed) do def self.from_array(lines_args) lines_args.map { |arg| new(arg) } end def initialize(content:) super( content:, parsed: LineParser.parse(content) ) end def brackets content.scan(/\[.+?\]/) end def some_images? brackets.any? { |item| item.match?(/\.(png|jpg)$/) } end def first_image brackets.find { |item| item.match?(/\.(png|jpg)$/) } end def indent_level content.match(/\A([\t ]*)/)[1].size end def indented? content.match?(/\A[\t ]/) end def to_obj content end def to_json(*) to_obj.to_json(*) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cosensee-0.6.0 | lib/cosensee/line.rb |