Sha256: 24b9253a0341d2ccf9c9b620b5d7426b54826cfcf8bf9145b9dc7bbfc085958b
Contents?: true
Size: 947 Bytes
Versions: 4
Compression:
Stored size: 947 Bytes
Contents
# frozen_string_literal: true module Lino module Model class Subcommand attr_reader :subcommand, :options def initialize(subcommand, opts = {}) opts = with_defaults(opts) @subcommand = subcommand @options = Hamster::Vector.new(opts[:options]) end def string [@subcommand, @options.map(&:string)].reject(&:empty?).join(' ') end alias to_s string def array [@subcommand, @options.map(&:array)].flatten end alias to_a array def ==(other) self.class == other.class && state == other.state end alias eql? == def hash [self.class, state].hash end protected def state [ @subcommand, @options ] end private def with_defaults(opts) { options: opts.fetch(:options, []) } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lino-3.2.0.pre.9 | lib/lino/model/subcommand.rb |
lino-3.2.0.pre.8 | lib/lino/model/subcommand.rb |
lino-3.2.0.pre.7 | lib/lino/model/subcommand.rb |
lino-3.2.0.pre.6 | lib/lino/model/subcommand.rb |