Class: ThumbnailSpec::EditSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/httpthumbnailer/thumbnail_specs.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args, options = {}) ⇒ EditSpec

Returns a new instance of EditSpec.



82
83
84
85
86
87
88
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 82

def initialize(name, args, options = {})
  name.nil? or name.empty? and raise MissingArgumentError, 'edit name'

  @name = name
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



67
68
69
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 67

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



67
68
69
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 67

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



67
68
69
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 67

def options
  @options
end

Class Method Details

.from_string(string) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 69

def self.from_string(string)
  args = ThumbnailSpec.split_args(string)
  args, options = ThumbnailSpec.partition_args_options(args)
  name = args.shift

  begin
    options = ThumbnailSpec.parse_options(options)
  rescue InvalidFormatError => error
    raise error.for_edit(name)
  end
  new(name, args, options)
end

Instance Method Details

#to_sObject



90
91
92
93
94
95
96
# File 'lib/httpthumbnailer/thumbnail_specs.rb', line 90

def to_s
  begin
    [@name, *@args, *ThumbnailSpec.options_to_s(@options)].join(',')
  rescue InvalidFormatError => error
    raise error.for_edit(name)
  end
end